DOC PREVIEW
Berkeley COMPSCI 164 - Lecture Notes

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Purposes of this CourseAn Extremely Abbreviated History of Programming LanguagesProblems to be AddressedKinds of Translators Programming Languages You May Not KnowUNIVERSITY OF CALIFORNIADepartment of Electrical Engineeringand Computer SciencesComputer Science DivisionCS 164 P. N. HilfingerSpring 2005CS 164: Programming Languages and CompilersClass Notes #1: Introduction1 Purposes of this CourseNot every programmer really has to kn ow how to build a compiler. Although this course hasthe structure of compilers as its ostensible topic, my real agenda is broader.• Acquire tools for building textual interfaces or other programs that process text.• Unders tand the common structure of programming languages, so as better to learn themand better design programs with language-like capabilities.• Acquire better intuition about program performance.• Acquire pr actice in reading, designing, and writing complex programs.2 An Extremely Abbreviated History of Programming Lan-guages• Initially, programs were either built into machines, or were entered by various electro-mechanical means, such as punched cards or tape (e.g., the Analytical Engine or theJacquard loom), or w ires and switches (e.g., the Eniac).• Around 1944 came the idea of encoding programs as numbers (machine language) storedas data in the machine, whence came the Machester Mark I and the EDSAC.• To make machine language easier to write, read, and maintain, assembly languages wereintroduced in the early 1950’s: symbolic names for instructions and data locations, butstill machine language—far from normal notation.• FORTRAN: mid-1950’s. Stands for FORmula TRANslator. Allowed use of usual al-gebraic notation in expressions; control structur es (jumps, etc.) still close to machinelanguage.1Introduction 2• LISP: late 1950’s—dynamic, symbolic data structures.• Algol 60: Europe’s answer to FORTRAN. Many syntactic features of modern languagescome from Algol 60. Also, it introduced the use of BNF (Backus-Naur Form), inspiredby Chomsky’s work, for describing syntax.• COBOL (late 1950s): introduces business-oriented data structures, esp. records (structsfor you C-folk).• 1960s s aw proliferation of increasingly elaborate languages: e.g., APL (array manipula-tion), SNOBOL (string manipulation), FORMAC (formula manipulation).• 1967–68: Simula 67, an Algol 60 derivate intended for writing discrete-event simulations,introduces concept of inheritance, making it the first “object-oriented” language in themodern sense.• 1968: Algol 68 attempted to synthesize both the numerical, FORTRANish line, therecord-oriented line (such as COBOL), with dynamic (pointer-based) data structures.It also tried to extend BNF into describing the entire language. This last effort madeit incomprehensible to many, and it faded away. Nevertheless, many C/C++ featuresmay be found in Algol 68. PL/1 was IBM’s clunkier but more commercially successfulattempt to meet the same goals.• 1968: announcement of the “Software Crisis.” Trend toward simple languages: Pascal,Algol W, C (later).• 1970s: emphasis on “methodology”—well-structured, modular programs. Several ex-perimental languages (like CLU). Smalltalk introduced, inspired in part by Simula 67.• Early 1970s: the Prolog language—declarative logic programming language. Originallyintended for natural language processing. Later, it is pushed as a general-purpose high-level programming tool.• Mid 1970s: ML (MetaLanguage) designed to implement LCF (Logic of ComputableFun ctions). This is a functional language with some interesting ideas—type inferenceand pattern-directed function definition. Has evolved since then and spawned variousprogeny (e.g., Haskell).• Mid-1970s: Dept. of Defense discovers it is supporting over 500 computer languages.Starts Ada project to consolidate (and then object-oriented Ada 95).• Increasing complexity in ideas of object-orientation until ca. 1980 with advent of C++,which has continued to complexify.• Reprising the move to simplicity in late 1970s, introduction of Java in early 1990s.Introduction 33 Problems to be Addressed• How do we describe a programming language?– Users must be able to understand it unambiguous ly.– Implementors must be able unders tand it completely.• Given a description, how to implement it?– How do we know we have it right?∗ Testing∗ Automating the conversion of description to implementation.– How do we save work?∗ Problem: multiple languages translated to multiple targets.∗ Automation (as above)∗ Designing so we can re-use pieces∗ Interpretation• How do we make the end result usable?– Reasonable handling of errors.– Detection of questionable constructs.– Compilation speed.∗ A standard approach: design language and translator to allow compiling pro-grams in sections.∗ Or, design translators to be really fast.– Execution speed. Problem: can make p rogram run f aster, if we are willing to haveslower compilation. How do we make this trade-off?– Binding time. Problem: how to handle program whose parts change constantly, oreven are unavailable at trans lation time?4 Kinds of TranslatorsThe purpose of translation is ultimately to execute a program. There is a spectrum of ap-proaches.Compilation: sourcetranslate−→ real machine languageexecute−→ actions/resultsInterpretation: sourcetranslate−→ virtual machine languageinterpret−→ actions/resultsDirect Execution: sourceinterpret−→ actions/resultsMost C/C++ systems are examples of compilation. Lisp interpretation is (in effect) anexample of direct execution (the “translation” performed by th e reader is trivial). Early JavaIntroduction 4systems used interpretation; now they use just-in-time compilation. These boundaries aremuddy, however. Some machines, for example, implement their instruction set by interpre-tation. Their “real” program is a microprogram that acts as an interpreter. For them, a Ccompiler is an examp le of an interpreter!All three of these strategies are specific to an implementation of a language; they are notinherent in the language. There are no such things as “interpreted languages” or “compiledlanguages.” For example, there are C interpreters, and there are Lisp compilers.Introduction 5ID#1=ID#1ID#5()TreeSyntaxAbstractStreamTokenProgramSourcePush #2AddIndexPush_Addr #4Push_Addr #3Code


View Full Document

Berkeley COMPSCI 164 - Lecture Notes

Documents in this Course
Lecture 8

Lecture 8

40 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?