42
CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively Lecture 1: Wherefore CS655? The use of <???> cripples the mind; its teaching should, therefore, be regarded as a criminal offence. Edsger W.Dijkstra, 1975 David Evans http://www.cs.virginia.edu/ ~evans CS655: Programming Languages University of Virginia Computer Science

CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

  • Upload
    cachez

  • View
    17

  • Download
    0

Embed Size (px)

DESCRIPTION

CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively. Lecture 1:Wherefore CS655?. The use of cripples the mind; its teaching should, therefore, be regarded as a criminal offence. Edsger W.Dijkstra, 1975. CS655: Programming Languages - PowerPoint PPT Presentation

Citation preview

Page 1: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

CS 655: Programming LanguagesScheming Schemers, Mocking Mockingbirds, and

Objecting Objectively

Lecture 1:Wherefore CS655?

The use of <???> cripples the mind; its teaching should, therefore, be regarded as a criminal offence.

Edsger W.Dijkstra, 1975

David Evanshttp://www.cs.virginia.edu/~evans

CS655: Programming LanguagesUniversity of VirginiaComputer Science

Page 2: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 2

Menu

• What is Computer Science?

• Goals for the Course

• Programming Languages– Design Tradeoffs

Send registration email by Sunday

Page 3: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 3

What is Computer Science?

Page 4: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 4

Let AB and CD be the two given numbers not relatively prime. It is required to find the greatest common measure of AB and CD.

If now CD measures AB, since it also measures itself, then CD is a common measure of CD and AB. And it is manifest that it is also the greatest, for no greater number than CD measures CD. But, if CD does not measure AB, then, when the less of the numbers AB and CD being continually subtracted from the greater, some number is left which measures the one before it.

Page 5: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 5

For a unit is not left, otherwise AB and CD would be relatively prime, which is contrary to the hypothesis. Therefore some number is left which measures the one before it. Now let CD, measuring BE, leave EA less than itself, let EA, measuring DF, leave FC less than itself, and let CF measure AE.

Since then, CF measures AE, and AE measures DF, therefore CF also measures DF. But it measures itself, therefore it also measures the whole CD. But CD measures BE, therefore CF also measures BE. And it also measures EA, therefore it measures the whole BA. But it also measures CD, therefore CF measures AB and CD. Therefore CF is a common measure of AB and CD.

I say next that it is also the greatest. If CF is not the greatest common measure of AB and CD, then some number G, which is greater than CF, measures the numbers AB and CD.

Now, since G measures CD, and CD measures BE, therefore G also measures BE. But it also measures the whole BA, therefore it measures the remainder AE. But AE measures DF, therefore G also measures DF. And it measures the whole DC, therefore it also measures the remainder CF, that is, the greater measures the less, which is impossible. Therefore no number which is greater than CF measures the numbers AB and CD. Therefore CF is the greatest common measure of AB and CD.

Euclid’s Elements, Book VII, Proposition 2 (300BC)

Page 6: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 6

By the word operation, we mean any process which alters the mutual relation of two or more things, be this relation of what kind it may. This is the most general definition, and would include all subjects in the universe. Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine... Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent.

Ada, Countess of Lovelace, around 1830

Page 7: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 7

What is the difference between Euclid and Ada?

“It depends on what your definition of ‘is’ is.”

Bill Gates

(speaking at Microsoft’s anti-trust trial)

Page 8: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 8

Geometry vs. Computer Science

• Geometry (mathematics) is about declarative knowledge: “what is”

If now CD measures AB, since it also measures itself, then CD is a common measure of CD and AB

• Computer Science is about imperative knowledge: “how to”

Computer Science has nothing to do with beige (or translucent blue) boxes called “computers” and is not a science.

Page 9: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 9

Next: My Goals for the Course

Page 10: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 10

Goal #1Make this the first real Computer Science most of you have taken.

Page 11: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 11

Imperative Knowledge

• The core of Computer Science is describing and reasoning about computations

• This class is about:– Tools for describing computations

(programming languages)– Tools for reasoning about those tools

(mostly formal semantics)

Page 12: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 12

Goal #2

Not waste your time.

Page 13: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 13

Graduate Students• Should make research their highest

priority (after sleeping, eating, and maintaining sanity and happiness)

• Should not spend time on courses except when it:– Makes them better researchers– Is of intrinsic interest and value

• Should be mature enough to decide what it is worthwhile to spend time on

Page 14: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 14

Hence:• Everything in this class is optional

– Except Problem Set 0: Registration Survey

• You should not take this course unless you believe most of the material we will cover is either:– Relevant to your research– Intrinsically cool and interesting

(Note: all of it is both)

Page 15: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 15

Evaluation

• I still need to grade you, of course...

• To get an A in this course, you need to convince me of your deep understanding of the most important course material.

Page 16: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 16

Ways to get an A in CS 6551. Do well on the assignments

or

2. Do well on an oral final exam

or

3. Produce a quality research paper on a relevant topic

or

4. Demonstrate your understanding through outstanding class contributions

Page 17: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 17

Questions

Next: Goals 3-8

Page 18: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 18

Goal #3When you need to invent a language (and most of you will at some point in your career) you will design it, not just make it up.

Page 19: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 19

What’s the difference?

Designed Just Made Up

Examples Esperanto, CLU English, C++

Properties Predictable Unpredictable

Ways to do something

One Many

Users ~1M; .5 - 15 ~1B; ~1M

Moral? A bigger army beats good design every time

But, good designs can influence people with armies

Page 20: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 20

Goal #4When you design your language, you will have sufficient knowledge of other languages not to repeat their mistakes, and solid enough theory background to describe your language well.

Page 21: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 21

Goal #5You will become better at programming and building systems. You will think more clearly and maybe even write better.

A language that doesn't affect the way you think about programming, is not worth knowing.

Alan Perlis

Page 22: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 22

Goal #6Some of you will do projects that lead to conference papers and influence your theses. All of you will be able to understand nearly all PLDI papers and many POPL papers.

Page 23: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 23

Goal #7

Enable at least half of you to understand at least half of R5RS Section 7.2 (2½ pages)

Page 24: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 24

Goal #8

FUN!

Page 25: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 25

Disclaimer

• Sorry, no refunds if not all goals are satisfied.

• Tell me your goals on the survey.

Page 26: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 26

Questions

Next: What is a Programming Language?

Page 27: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 27

What is a language?

Webster:

A systematic means of communicating ideas or feelings by the use of conventionalized signs, sounds, gestures, or marks having understood meanings.

Page 28: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 28

Nerdy Linguist’s Definition

A description of pairs (S, M), where S stands for sound, or any kind of surface forms, and M stands for meaning. A theory of language must specify the properties of S and M, and how they are related.

Page 29: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 29

Programming Language

A language (according to the Nerdy Linguist’s definition) intended to be read and written by humans and processed by machines.

Stricter definition add:

that has some notion of control flow.

Page 30: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 30

Some other definitions

• Bruce MacLellan’s definition:A language that is intended for the expression of computer programs and that is capable of expressing any computer program.

• Ravi Sethi’s definition: Notations used for specifying, organizing, and reasoning about computations.

Page 31: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 31

What makes a PL important?

Page 32: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 32

Amazon.com sales rank for best-selling book related to language(30 November 1999)

Java

Basic

C C+

+

Tcl

CO

BO

L

Eiffel

Pascal

Ad

a

Lisp

FO

RT

RA

N

HT

ML

100

1000

10000

100000

No books in print:Algol60, CLU, Simula

Lots of People Learn It

Page 33: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 33

Monster.com job listings in Virginia matching language(30 November 1999)

C++

Java

Basic

HTM

L

CO

BO

L Ada

Tcl

FO

RTR

AN

Pascal

1

10

100

1000

You Can Get a Job

No job listings:Algol60, CLU, Simula

Page 34: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 34

Changes How Programmers ThinkInfluences other Languages

• FORTRAN - use a high level language

• Algol60 - program in a structured way

• Simula - use classes

• CLU - use data abstraction

• FP - program without state

Page 35: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 35

Languages we will focus on• Scheme

– Simplest, cleanest, most elegant language I know– Extremely powerful tool for describing computations

• CLU– Because I like it, and its my course– Because it has the best support for data abstraction

• Java– Because it is popular and modern

• Others, possibly including:– Ada, Algol60, Algol68, C, C++, Eiffel, Euclid, FL, ML,

Linda, Pascal, Sather, Simula, Tcl

Page 36: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 36

Language Design

Art and Engineering

Page 37: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 37

Language Design as EngineeringSafety PerformanceJava, CLU FORTRAN, BLISS, C

Ease of Use Ease/size of ImplementationBASIC, CLU Forth, C

Orthogonality Safety, SimplicityAlgol68 Pascal

Simplicity Expressiveness Scheme Common LISP

Page 38: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 38

Example: Is assignment an expression?

• Wulf (BLISS): Of course, everything is

a := if .c >4 then .e else f := 7• Richie (C): Yes, why not

while (x = 0) x++;

but not: x = if (a > 3) 4 else 5;• Wirth (Pascal): No, only math-like things

are expressions

Who’s right?

What were their design tradeoffs?

Page 39: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 39

C’s main design requirementMemory Space

24K on PDP-11 total. Needed to fit OS, compiler, and leave a little room for user programs. The “good” languages and operating systems of the day (Algol60, Multics) didn’t fit.

Note: C++’s main design requirement: be as compatible as possible with C.

Page 40: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 40

Language Design as Art

• Aesthetics matter • Readability is usually more important

than Writability– CLU vs. APL

• Intuitive meaning more important than formal semantics– But formal semantics necessary to make

sure we agree on intuitive meaning

Page 41: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 41

Interaction of Art & EngineeringExample: C

void test (int x) {while (x = 1) {

printf (“I’m an imbecile!”); x = x + 1;

}}

Art: use = for assignment (not :=)Engineering: make assignments expressions,

no Boolean type, weak types, etc.

Page 42: CS 655: Programming Languages Scheming Schemers, Mocking Mockingbirds, and Objecting Objectively

18 Jan 2001 CS 655: Lecture 1 42

Charge• Think about my definition of Computer

Science– Send me a better one if you can

• Think about how well the languages you use are designed

• Send me your registration survey by Sunday

• Next time: Scheme