Introduction to Programming Languages and Compilers ..., Study notes of Programming Languages

How are Languages Implemented? • Two major strategies: – Interpreters (older, less studied). – Compilers (newer, more extensively studied).

Typology: Study notes

2022/2023

Uploaded on 05/11/2023

mjforever
mjforever 🇺🇸

4.8

(25)

254 documents

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Prof. Hilfinger CS 164 Lecture 1 1
Introduction to Programming Languages and
Compilers
CS164
11:00-12:00 MWF
10 Evans
Notes by G. Necula, with additions by P. Hilfinger
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

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
    • Including old code
  • 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
    • (2 wks! 2 hrs)

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
    • The diagram is a tree

Diagramming a Sentence This line is a longer sentence article noun verb article adjective noun subject object sentence