COMP 411 Principles of Programming Languages (Fall 2011)
Professor Robert "Corky" Cartwright
Professor Swarat Chaudhuri
Department of Computer Science
Rice University
Houston, Texas, USA
Fall 2011: Room 1042, Duncan Hall, Monday, Wednesday, Friday, 1:00pm–1:50pm
For more information on the course staff including office hours, see
course information.
Course News
- Please join the course mailing list by subscribing.
- If you haven't found a partner, send an email to the comp411-l mailing list.
- Students looking for Project 1 partners:
Please get in touch with each other. Issues to keep in mind:
- Make sure you have the time to work on the project together.
- Make sure that at least one partner has Java programming experience.
- Try to find a permanent partner for the rest of the class; it's a lot easier to work with the same student than to switch.
- You may choose to work alone. We do not allow groups of more than two students, even if there is an odd number of students in the class.
- If you haven't found a partner and are not on this list, send an email to the comp411 mailing list.
- If you are on this list but have already found a partner, email Corky to remove you from this list.
Summary
COMP 411 is an introduction to the principles of programming languages. It focuses on:
- identifying the conceptual building blocks from which lanugages are assembled and
- specifying the semantics, including common type systems, of programming languages.
In the lecture materials, interpreters are written in concise functional notation using Scheme.
In some cases, supplementary material showing
how the same interpreters can be written in OCaml (using explicit typing) are provided. While Java is a very good vehicle
for implementing these interpreters, it is not a good conceptual representation because it is much too wordy and
the OO structure obscures the simple algebraic structure of abstract syntax and structural recursion used to defin
interpretation.
A secondary theme is software engineering. All of the programming assignments in this course are conducted in Java using test-driven development and pair-programming, two of the major tenets of Extreme Programming.
COMP 411 consists of three parts:
- The first part focuses on specifying the syntax and the
semantics of programming languages. The former is introduced via
simple parsing (translations) of program text into abstract
syntax. More detailed aspects of parsing (such as lexical analysis and advanced parsing
methods) are left to COMP 412, a
course on compilers. The semantics of a comprehensive collection
of programming language constructs is specified using
interpreters and reduction (textual rewriting) systems. The constructs include
arithmetical and conditional expressions, lexical binding of
variables, blocks, first-class functions, assignment and
mutuation, simple control constructs (loop exits, first-class
continuations, simple threads), and dynamic dispatch.
- The second part illustrates how interpreters and reduction
semantics can be used to analyze important behaviorial properties of
programming languages. Two examples are covered: type safety and
memory safety. Type safety guarantees that programs respect
syntactically defined type abstraction boundaries and never
raise certain classes of error signals. Memory safety guarantees
that programs release memory if it is provably useless for the
remainder of the evaluation. Type safety typically depends on
memory safety.
- The third part shows how interpreters can systematically be
transformed so that they use fewer and fewer language
facilities. The key transformations are the explicit
representation of closures as records and the conversion of
program control flow to continuation-passing style. Using these
transformations, a recursive interpreter can readily be be
re-written in a low-level language like C/C++ or even assembly
language. These transformations can be applied both to
interpreters and to arbitrary programs. if we apply these
transformations to an interpreter, the result is a low-level
interpreter that is easily implemented in machine code. The
process of applying these transformations to arbitrary input
programs yields a high-level description of program compilation,
a process which is explored in more detail in COMP 412.
The course enables students to analyze the semantics and pragmatics of the old, new, and future programming languages that they are likely to encounter in the workplace (e.g., Fortran, C, C++, Java, Visual Basic, C#, Perl). They will also be able to build efficient interpreters for new languages or for "special-purpose" languages embeded in software applications. Finally, they will be much
be equipped as software developers because they will understand how to define and implement whatever linguistic extensions are
appropriate for simplifying the construction a particular software system.
Notes on the common mathematifcal notation
used in operational semantics, some of which will be used in class.
Course Information
Please take a look at the course information some of
which was discussed during the first few class lectures.
Assignments
Please refer to the assignments column in the below.
Lectures
Powerpoint slides for selected lectures are available in this directory.
#
|
Date
|
Day
|
Topic
|
Reference
|
Assignment
|
1
|
8/22
|
M
|
Information &
Motivation
|
|
|
2
|
8/24
|
W
|
Parsing
|
Component Pascal Syntax Diagrams
|
Project 1 assigned, 8/24
Reference: Notes on Object-Oriented Program Design
|
3
|
8/26
|
F
|
4
|
8/29
|
M
|
The Scope of Variables
|
PLAI, ch. 3-4
|
5
|
8/31
|
W
|
Syntactic Interpreters
|
Brief Review of Lectures 1-6
|
6
|
9/2
|
F
|
|
|
9/5
|
M
|
Labor Day Holiday
|
|
|
7
|
9/7
|
W
|
A Meta Interpreter for LC
Eliminating Meta-errors
|
PLAI, Ch. 4-6
|
Project 1 due 12 noon, 9/7
Project 2 assigned, 9/7
|
8
|
9/9
|
F
|
9
|
9/12
|
M
|
10
|
9/14
|
W
|
Data Domains Supporting Recursive Definitions
Recursive Definitions and Environments
|
Domain Theory: An Introduction
The Why of Y
Recursive Programs as Definitions in First-Order Logic
Types as Intervals
The Lambda Calculus as a Model of Computation
Supplemental Material
|
11
|
9/16
|
F
|
12
|
9/19
|
M
|
13
|
9/21
|
W
|
Recursive Binding
|
14
|
9/23
|
F
|
Eliminating Binding (lambda)
|
Essentials, ch. 3.7, 3.9
Hand Evaluation Exercises
Solution to Hand Evaluation Exercises
|
Project 2 due 12 noon, 9/23
Project 3 assigned, 9/23
|
15
|
9/26
|
M
|
Assignment and Mutability
|
16
|
9/28
|
W
|
16 (cont.)
|
9/30
|
F
|
17
|
10/3
|
M
|
Run-time Environment Representation and Control
|
Essentials, ch. 7, 8
Powerpoint slides taken from Sebesta's book Concepts of Programming Languages
|
20
|
10/5
|
W
|
Hoare Logic
|
10/7
|
F
|
Hoare Logic
|
|
|
10/10
|
M
|
Midterm Recess — No Classes
|
|
Hoare Logic
|
10/12
|
W
|
Hoare Logic
|
|
Project 3 due 12 noon, 10/12
Project 4 and 4xc assigned, 10/12
Sample Exam 1
Solutions to Sample Exam 1
|
Hoare Logic
|
10/14
|
F
|
Hoare Logic
|
|
Exam 1 Review
|
10/17
|
M
|
Sample Exam 1
|
Essentials, ch. 5
|
Exam 1 distributed in class, 10/17
Binding/bound occurrences, Problem 3
Call-by-name hand evaluation, Problem 5(i)
Call-by-value hand evaluation, Problem 5(ii)
|
21
|
10/19
|
W
|
Object-Oriented Languages
Featherweight Java (Optional)
|
Project 4 due 12 noon, 10/21
Project 5 and 5xc assigned, 10/21
|
21 (cont.)
|
10/21
|
F
|
22
|
10/24
|
M
|
What Is a Type?, Types and Safety
|
Essentials, ch. 4
|
Exam 1 due in class, 10/24
|
22
|
10/26
|
W
|
Exam Discussion
|
|
4xc due 12 noon, 10/26
|
22
|
10/28
|
F
|
Types and datatype
|
Essentials, ch. 6
|
23
|
10/31
|
M
|
23
|
11/2
|
W
|
Polymorphism
|
|
Project 5 and 5xc due 12 noon, Monday, 11/7
Project 6 (PDF) assigned, Monday, 11/7
|
24
|
11/4
|
F
|
Implicit Polymorphism
|
Type Inference Study Guide
|
25
|
11/7
|
M
|
Final Words on Types
|
|
26
|
11/9
|
W
|
The Meaning of Function Calls
|
Essentials, ch. 8
|
27
|
11/11
|
F
|
Continuation-Passing Style
|
28
|
11/14
|
M
|
29
|
11/16
|
W
|
Explaining letcc and error
|
29
|
11/18
|
F
|
The True Meaning of Function Calls
|
Project 7 assigned, 11/18
|
30
|
11/21
|
M
|
Garbage Collection
|
Uniprocessor Garbage Collection Techniques
Dynamic Storage Allocation Survey
|
31
|
11/23
|
W
|
Sample Exam 2
Sample Exam 2 With Solutions
Project 6 due noon, 11/23
Exam 2 handed out in class, 11/23
|
|
11/25
|
F
|
Thanksgiving Recess — No Classes
|
|
|
32
|
11/28
|
M
|
Garbage Collection II
|
|
|
34
|
11/30
|
W
|
Operational Semantics of OO Languages (notably Java)
|
|
|
42
|
12/2
|
F
|
Java Concurrency
|
|
Project 7 due at 11:59 PM, 12/2
Exam 2 due at 11:59 PM, 12/2
|
Language Resources
- Java
-
SDK Download
-
Generic Java Documentation
-
API Reference
-
DrJava Programming Environment
-
Elements of Object-Oriented Program Design by Prof. Cartwright
- Scheme
-
How to Design Programs
-
DrScheme Programming Environment
- OCaml
-
OCaml Book
-
O'Caml Language
-
MetaOCaml
-
OCamlLex
-
Using "Ledit" to make Ocaml recognize arrow keys
-
Haskell
-
Scala
Additional References
- Krishamurthi, Shriram. Programming Languages: Application and Interpretation.
Online at http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/.
This book is a descendant of lecture notes created by Shriram for a version of this course when Shriram was a teaching assistant over a decade
ago.
- Friedman, Wand, and Haynes, Essentials of Programming Languages, 2nd ed. (MIT Press, 2001)
You can take a look at the following two chapters, which the authors prepared for the second edition, without buying the book:
-
Parameter Passing ( local file, PDF)
-
Types and Type Inference ( local file, PDF)
-
Evaluation rules for functional Scheme ( PDF)
-
References on evaluating Jam programs
-
Lecture Notes on Types I
-
Lecture Notes on Types II
-
Introduction to System F (Polymorphic Lambda-Calculus)
-
Scheme code from Class Lectures
-
The Essence of Compiling with Continuations by Flanagan et al.
-
Uniprocessor Garbage Collection Techniques by Paul Wilson
-
Garbage Collection [canonical textbook] by Jones and Lins
-
Space Efficient Conservative Garbage Collection by Hans Boehm ( local file, PDF)
- Hans Boehm's Conservative GC Webpage
-
The Java Virtual Machine. The most basic expository articles appear at the end of the index. Read it from bottom up.
-
Java Memory Model
-
Revised Thread Synchronization Policies in DrJava (doc) ( pdf). Since DrJava is built using the Java Swing library, it must conform to the synchronization policies for Swing. Unfortunately, the official Swing documentation is sparse and misleading in places, so this document includes a discussion of the Swing synchronization policies.
-
Lesson: Concurrency in Swing. This lesson discusses concurrency as it applies to Swing programming. It assumes that you are already familiar with the content of the Concurrency lesson in the Essential Classes trail.
-
Concurrency in Swing Text
-
The Last Word in Swing Threads
-
Old Course Website
Accomodations for Students with Special Needs
Students with disabilities are encouraged to contact me during the first two weeks of class regarding any special needs. Students with disabilities should also contact Disabled Student Services in the Ley Student Center and the Rice Disability Support Services.