Programming languages and compilers I, Fall 2010

Logistics

Lectures: Thu 3:20–6:20pm in Hill 250

Professor: Chung-chieh Shan (ccshan at cs)
Office hours: Tue 4:30–6pm in CoRE 306 (starting on Sept 14), or email to make an appointment

Teaching assistant: Nishat Islam (nislam at cs)
Office hours: Mon 2–4pm in Hill 486 (note that Mon 9/6 is rescheduled to Wed 9/8)

Synopsis

Not many of us build general-purpose programming languages or general-purpose compilers. But all of us have built programs that are so long, they are overwhelming to understand; so complicated, they are impossible to trust; so repetitive, they are boring to write. In this course, we will practice two solutions to this problem that should be in every computer scientist's toolbox.
  1. Use logical reasoning to prove that a program is correct, assure that a language is sound, or find counterexamples such as test cases that fail.
  2. Automate code generation to reduce code duplication, clarify the intended meaning of the program, and improve run-time performance.
The first half of the course (3:35–4:30pm) teaches how to prove basic properties of programs and programming languages, using the software assistant Coq. The second half of the course teaches how to define reusable code generators, using the functional language Haskell.

This course requires that you already know the basic principles that underlie all programming languages, so that you can quickly and independently pick up new languages as you go. It also requires that you know the typical structure of a basic interpreter or compiler for a simple language, such that you can easily build a calculator that turns the input "3*(6+8)" into the output "42". One way to acquire this background knowledge is to take CS314 or CS415. Finally, mathematical maturity helps as always.

Workload

There will be weekly homework assignments using Coq and Haskell. There will not be any midterm or final exam. Instead, as a term project, each of you will design and implement a domain-specific code-generation language to solve a practical programming problem that is hard to solve using the abstraction and assurance facilities already provided by a general-purpose language. About halfway into the course, you will give a short presentation of your ongoing project. At the end of the course, you will write a paper to describe the why, what, and how of your finished project. You may use any language(s) you like in your project.

You are responsible for checking your email at the official address according to the Rutgers registrar, and for checking this Web site for announcements.

You are also responsible for participating in our online discussion.  On this Web site, follow the link "discussion and private messages", then "class discussion and questions".

When sending email to course staff or posting to the online discussion, use a descriptive subject.  Put "515" in the subject of emails to course staff, so that the message stands out and is easy to categorize.  See "The do's and don'ts of posting on Google Groups" for more information on online discussion etiquette.

Grading

Participation: 10%
Homework assignments in part 1 (using Coq): 40%
Homework assignments in part 2 (using Haskell): 30%
Interim project presentation: 10%
Final project (paper and software): 10%

Each homework assignment is due in one week by midnight unless otherwise indicated. Each day late discounts the grade by 10%.  Please submit your work on this Web site under "assignments".

Tentative schedule

  • 9/2
    • Basics: Functional programming and reasoning about programs
    • A pattern-match compiler for C; compositional translation using a code-generation library
  • 9/9
    • Lists: Products, lists and options
    • Abstract syntax trees
  • 9/16
    • Poly: Polymorphism and higher-order functions
    • Names, hygiene; higher-order abstract syntax, continuation passing
  • 9/23
    • Poly: More about Coq
    • Types
  • 9/30 (Guest lecture)
  • 10/7
    • Ind: Propositions and evidence
    • Parsing; monads, combinators
  • 10/14
    • Logic: Logic in Coq
    • Pretty printing
  • 10/21
    • Rel: Properties of relations
    • Project presentations
  • 10/28
    • Imp: Simple imperative programs
    • Project presentations
  • 11/4
    • Equiv: Program equivalence
    • Avoiding repeated computation; let-insertion
  • 11/11
    • Equiv: Constant folding
    • Partial evaluation; memoizing positive information
  • 11/18
    • Hoare: Hoare logic
    • String matching; fixpoint, memoizing negative information
  • 11/25 (Thanksgiving recess)
  • 12/2
    • Smallstep: Small-step operational semantics
    • Abstract interpretation; memoizing partial information
  • 12/9
    • Stlc: The simply typed lambda-calculus
    • Multiple semantics; type-class overloading

Software

Be sure to install the following software on the machine(s) you regularly use:
  1. Coq 8.2, including CoqIde
  2. Haskell Platform and the Language.C library
If you have a laptop, please feel free to bring it to class instead of using the lab machines. To use the lab machines, you need to have an account on the iLab domain. You can create the account on-line. You can install the Language.C library in your account by typing cabal update; cabal install --user language-c

A to-the-point introduction to Haskell is A Gentle Introduction to Haskell. A more recent book is Real World Haskell.

A short introduction to Coq is A Short Introduction to Coq. A comprehensive book is Interactive Theorem Proving and Program Development, Coq'Art: The Calculus of Inductive Constructions.