Introduction to Programming Languages and Compilers at UC Berkeley, Lecture notes of Programming Languages

A course outline for CS164: Introduction to Programming Languages and Compilers at UC Berkeley. The course is an upper-level elective and focuses on teaching programming language principles through DSL design and implementation. The course includes nine weekly projects, covering topics such as interpreter, parser, web browser, and language abstractions. The final exam is replaced with a project where students create a DSL in two weeks. The document also includes testimonials from students who found the course challenging but rewarding.

Typology: Lecture notes

Pre 2010

Uploaded on 05/11/2023

christin
christin 🇺🇸

4.6

(18)

263 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Hack Your Language!
CS164: Introduction to Programming
Languages and Compilers, Fall 2010
UC Berkeley upper-level elective course
Ras Bodik
Thibaud Hottelier
James Ide
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Introduction to Programming Languages and Compilers at UC Berkeley and more Lecture notes Programming Languages in PDF only on Docsity!

Hack Your Language!

CS164 : Introduction to Programming Languages and Compilers, Fall 2010

UC Berkeley upper-level elective course

Ras Bodik Thibaud Hottelier James Ide

The Why of Who and What

I used to teach a successful compiler course:

Aha! ugrads are future developers , not compiler jocks.

Also mindshare. Reverse the brain drain to AI and bio.

you know what these are

Take cs164. Become unoffshorable.

“We design them here, but the labor is cheaper in Hell.”

Principles behind course design

Teach PL principles via DSL design and implementation

Hard in a messy language. DSLs in Lua, which is in Python.

Learn how to design and implement a DSL

Final exam replaced with a project: create a DSL in 2 weeks.

Piggybacking: three birds with one stone

coroutines + backtracking + regexes; …

Parsing: most of us want to deemphasize it

Yet it’s one of the more useful skills. How to teach it?

Language abstractions

prolog with coroutines, it’s a few lines; later used

yield: full coroutines bytecode compiler, regex, backtracking

interpreter closures, lexical scoping, desugaring, iterators

The Parsing story

  1. Write a **random expression generator.
  2. Invert** this recursive generator into a parser by replacing print with scan and random with oracle.
  3. Now write this parser in Prolog, which is your oracle. This is your recursive descent parser.
  4. Look, this prolog parser has no negation. It’s Datalog!
  5. Datalog can be evaluated bottom-up, with dynamic programming. Now we got CYK parser.
  6. Datalog evaluation can be optimized with a Magic Set Transformation, which yields Earley Parser. (^8)

Web browser: layout and scripting

Rx from events to high-order dataflow; reactive programming a`la RxJS

jQuery embedded DSL for declarative DOM manipulation

layout engine from constraints to attribute grammars; add OO to language

Contest winners in yellow jerseys