Download Introduction to Programming Languages and Compilers ... and more Study notes Programming Languages in PDF only on Docsity!
Introduction to Programming Languages and Compilers CS 11:00-12:00 MWF 10 Evans Notes by G. Necula, with additions by P. Hilfinger
Administrivia
- Course home page: http://www-inst.eecs.berkeley.edu/~cs
- Concurrent enrollment: see me after class
- Pick up class accounts at the end of lecture Wednesday
- Pick a partner
- We’re understaffed. Those in 10-11, 3- sections might consider moving to 9-10, 4-5; will discuss more in section meetings.
Academic Honesty
- Don’t use work from uncited sources
- We use plagiarism detection software
- 6 cases in last few semesters
PLAGIARISM
The Course Project
- Course has hidden agenda: programming design and experience.
- Substantial project in parts.
- Provides example of how complicated problem might be approached.
- Validation (testing) is part of the project.
- Also a chance to introduce important tool: version control, which we’ll use to monitor your progress
- General rule: start early!
(Short) History of High-Level Languages
- Initially, programs “hard-wired” or entered electro- mechanically: Analytical Engine, Jacquard Loom, ENIAC, punched-card-handling machines
- Programs encoded as numbers (machine language) stored as data: Manchester Mark I, EDSAC.
- 1953 IBM develops the 701
- All programming done in assembly
- Problem: Software costs exceeded hardware costs!
- John Backus: “Speedcoding”
- An interpreter
- Ran 10-20 times slower than hand-written assembly
FORTRAN I
- 1954 IBM develops the 704
- John Backus
- Idea: translate high-level code to assembly
- Many thought this impossible
- 1954-7 FORTRAN I project
- By 1958, >50% of all software is in FORTRAN
- Cut development time dramatically
After FORTRAN
- Lisp, late 1950s: dynamic, symbolic data structures.
- Algol 60: Europe’s answer to FORTRAN: modern syntax, block structure, explicit declaration. Set standard for language description. Dijkstra: “A marked improvement on its successors.”
- COBOL: late 1950’s. Business-oriented. Records.
The 60s Language Explosion
- APL (arrays), SNOBOL (strings), FORMAC (formulae), and many more.
- 1967-68: Simula 67, first “object-oriented” language.
- Algol 68: Combines FORTRAish numerical constructs, COBOLish records, pointers, all described in rigorous formalism. Remnants remain in C, but Algol68 deemed too complex.
- 1968: “Software Crisis” announced. Trend towards simpler languages: Algol W, Pascal, C
And on into the present
- Complexity increases with C++.
- Then decreases with Java.
- Then increases again (C#).
- Proliferation of little or specialized languages and scripting languages: HTML, PHP, Perl, Python, Ruby, …
Problems to address
- How to describe language clearly for programmers, precisely for implementors?
- How to implement description, and know you’re right?
- Automatic conversion of description to implementation
- Testing
- How to save implementation effort?
- Multiple languages to multiple targets: can we re-use effort?
- How to make languages usable?
- Handle errors reasonably
- Detect questionable constructs
- Compile quickly
Lexical Analysis
- First step: recognize letters and words.
- Words are smallest unit above letters This is a sentence.
- Note the
- Capital “T” (start of sentence symbol)
- Blank “ “ (word separator)
- Period “.” (end of sentence symbol)
More Lexical Analysis
- Lexical analysis is not trivial. Consider: ist his ase nte nce
- Plus, programming languages are typically more cryptic than English: *p->f+=-.12345e-
Parsing
- Once words are understood, the next step is to understand sentence structure
- Parsing = Diagramming Sentences
Diagramming a Sentence This line is a longer sentence article noun verb article adjective noun subject object sentence