CSE230 TUESDAY JANUARY 6, 1998 ADMINISTRATION This is an introductory-graduate level course on programming languages. The main topics are - functional programming - other modern PL ways of thinking, in particular objects - lambda calculus (the mathematical foundation of PLs) - denotational semantics Organization: - HW assignment every week - in-class final Fact: we have no TA. Corollary: HW assignments will be very similar to last year's. Corollary: There will be a final exam. Corollary: You will be forming pairs to grade the assignments yourselves. Books: Chris Reade. Jeff Ullman. R. D. Tennent. J. Gosling. Lecture notes and handouts will be available through the class web page at http://www-cse.ucsd.edu/classes/wi98/cse230/ THE NEED FOR HIGH-LEVEL PROGRAMMING The basic theme of this course is that programming should be done at the highest possible level, where the greatest number of errors can be avoided. Errors are avoided by having the computer fill in details automatically. When a human has to take care of details, errors arise: "To err is human". FUNCTIONAL PROGRAMMING Standard PLs are imperative for example C, C++, Ada, Fortran, Cobol all the languages in really widespread use They are called imperative because commands are the basic constructs. "Command" means "order", "instruction". It's a better name than "statement" which sounds misleadingly declarative. In particular, assignment of a new value to an existing variable is the basic operation. The assignment command evolved by abstraction from the operations provided by computers with von Neumann architectures: - separate memory and CPU - memory consists of changeable cells with addresses - program stored in memory with a program counter - data stored in memory with transfers to and from registers A historical note: automatically incrementing the program counter after each instruction is a separate idea, and the first step towards structured programming. WHAT IS "ABSTRACTION"? 1) Abstraction is the process of omitting unimportant details. 2) A programming language is an abstraction of a computing machine. 3) A PL is higher-level if more machine details are abstracted away. In standard imperative languages: - words in memory are abstracted to integers, characters etc. - incrementing the program counter is abstracted to sequencing - assignments to the program counter are abstracted to jumps - in structured programming, standard patterns of jumps are abstracted to if-then-else and while-do strucures - etc. This is still rather low-level. The programmer must (1) choose an order in which to sequentialize computation unlike in an expression such as 2*3 + 4*5, where it is not specified which multiplication is performed first (2) divide up large values into word-sized chunks even in Pascal, a function cannot return a record in K&R C, pointers must be used often as proxies for large values (3) allocate and recapture memory again, by contrast the intermediate storage used for arithmetic subexpressions is managed automatically Note that "silicon compilers", e.g. synthesizers for behavioral VHDL, cannot cope with (2) and (3). This was one of the topics of the talk by Bill Lin (a faculty candidate) in ECE on Jan 8, 1996.