CS 334: Principles of
Programming Languages

Prof. Morgan McGuire morgan@cs.williams.edu
Lecture is Tuesday and Thursday, 9:55am - 11:10am TCL 206
Office hours are TW 2:30-4:00pm in TCL 308

TA M. Catalin Iordan, Marius.C.Iordan@williams.edu
Office hours MT 8:00pm-10:00pm in TCL 312; W 8:00pm-11:00pm in TCL 312

[Schedule] [Reading] [Some Presentation Topics] [Latest Programming Language Notes] Schedule


Req = Required reading for which you are responsible (i.e., fair game for exam and homework questions)

Sup = Optional, supplemental reading to provide another perspective or longer explanation of the lecture topic and required reading

Exp = Optional, supplemental reading to extend the lecture topic, often a research paper

Hwk = Homework going out on this day

Due = Homework due at the beginning of class on this day
Feb. 4 (This is actually a Wednesday)
The Halting Problem


Feb. 10Scheme
  • Formal grammars in Backus-Naur form (BNF)
  • The Scheme language (examples.ss)
  • The Dr. Scheme IDE
  • The Scheme expression grammar


Feb. 12 Functional Programming I

  • HW1: Recursion

Feb. 17 Functional Programming, Part II

    PLAI Ch. 1

Feb. 19 Implementing a Language

  • PLAI Ch. 1 (again!), 2
    • HW2: Functional Programming

    2-min presentation by Dave Moore: Map-Reduce at Google
    Feb. 24 Substitution
    • Arrow and product types
    • A substitution interpreter (subst.ss)
    • Bound and free variables

    • PLAI Ch. 3
      • Tcl - a popular scripting language based on substitution

      Feb. 26 Exam Review
      • The Halting Problem
      • Scheme Expressions
      • BNF and Syntax
      • First Class Procedures
      • Substitution Interpreter
      • HW3: Interpreter
      2-min presentation by Dan Fast: LAMBDA in Java
      Mar. 3

      Exam 1
      • Covers Halting Problem through Substitution
      • In class: 75 min
      • Closed book, 1/2 page original, hand-written notes
      • Similar to homework questions
      Mar. 5 The λ Calculus
      • Eager and lazy evaluation
      • Lambda Calculus Semantics
      • Currying
      • Scheme LAMBDA and App in λC
      • Church Lists: CONS in λC (rewrite.ss)
      • PLAI 22
        • HW4: If Only...

        Mar. 10 The Y Combinator
        Mar. 12 Environments
        • The price of substitution
        • Deferring substitution
        • Semantics vs. implementation
        • Environments and binding
        • Mutation
        • Variable scope
        • SET! (PLT Scheme Doc) and BEGIN
        • Introduction to closures

        • PLAI Ch. 4
        • Eph Interpreter Source (read over the next two weeks) (eph.zip)
          • HW5: Lambda Calculus

          Mar. 17 Closures
          • Implementing procedures
          • Lexical and dynamic scope
          • APPLY and EVAL revisited
          • Implementing MAP (map.ss)
          • Semantics of LET, LET*, LETREC
          • Native/built in procedures

          • PLAI Ch. 5, 6

            Erdem Sahin will present on a topic of his choice.

            Mar. 19 Continuations
            • Apply/eval revisited
            • Continuations and control flow
            • RETURN, BREAK, THROW, and backtracking (throw.ss return.ss)

            • PLAI Ch. 19
              • PLAI Ch. 15-20 (they're short)
              • HW6: Save the Environment I

              SPRING RECESS
              Apr. 7 Macros

              • PLAI 36 parts 1, 2, 5, 6

                Apr. 9 Operational Semantics
                • Formal progress rules
                • Literal Expressions vs. Values (review)
                • Rules with environments
                • Introduction to types
                • Exam Review:
                  • Halting Problem
                  • Grammars
                  • Interpreters
                  • Functional Programming
                  • Stream Programming
                  • λ Calculus
                  • Closures
                  • Macros
                  • How to learn a language

                • PLAI Ch. 23
                • pl-notes (09-04-09 version), section 5
                  • HW7: Save the Environment II

                  Apr. 14
                  Exam 2

                  Covers all material from the course. Emphasis on:

                  • λ Calculus
                  • Lazy and Eager Evaluation
                  • Environments
                  • Macros
                  • Review slides (not comprehensive)
                  • In class: 75 min
                  • Closed book, 1/2 page original, hand-written notes

                  Apr. 16 Type Judgments
                  • Validity vs. correctness
                  • Types are sets of values
                  • Type judgements are reductions for types
                  • Type annotations
                  • Procedure Types

                  • PLAI Ch. 24, 25
                  • Steele, Growing a Language, 1999 (for HW9, not discussed in class today)
                    • HW8: Operational Semantics

                    Evan Weintraub will give a 2-minute presentation comparing natural language and programming language syntax
                    Apr. 21 Type Inference
                    • Discussion of Judgements
                      • Curry-Howard correspondance
                      • Casts
                    • Type Inference
                      • T-Lambda revisited
                      • The Hindley-Milner-Damas unification algorithm
                      • Patterns and inference in ML
                    • Syntax Revisited (slides)

                    • PLAI Ch. 30 (you may skip 30.1.0, 30.1.2, 30.5.3)

                      Sam Blackshear will give a 2-minute presentation on Alan Turing
                      Apr. 23 Polymorphism

                      • PLAI Ch. 29
                        • HW9: Judgements

                          Brian Citro and Kelsey Levine will each give a 2-minute presentation on topics of their choice
                          Apr. 28 Subtypes
                          • Subtypes
                          • Covariance and contravariance
                          • Objects and inheritance
                          • The curious cases of null and void


                          Austin presents GOTO and scope; Claire presents reactive languages
                          Apr. 30 Memory Management I
                          • Protecting state with closures: next procedure in Scheme
                          • (Exploring semantics)
                          • Stack and heap revisited
                          • Constructors and destructors in C++ (constructor.cpp)
                          • Manual mangement: new and delete in C++
                          • Dangling references and memory leaks (...and buffer overrun exploits)
                          • Identifying dead objects is undecidable
                          • Memory management for Trees is easy
                          • Reference counting for Directed Acyclic Graphs (ala Python)
                          • Extending C++ with reference counting (ReferenceCount.cpp)

                          • PLAI Ch. 21
                            • HW10: Recursion (Now due 5/5/09 because of server and network outages during in the heat wave)

                            Josh will give a 2 minute presentation on Expect
                            May 5Memory Management II

                            • Cycle detection is difficult
                            • Free lists and allocation lists (alloc.py)
                            • Block allocation
                            • The Mark-Sweep collection algorithm (mark-sweep.py)
                            • Conservative collection
                            • Fragmentation
                            • Stop-and-Copy collection algorithm
                            • HW10: Babel (Extended Deadline)

                            Jeff, Tyler, and Moaj will present on Algol, ???, and AWK
                            May 7Concurrency
                            • Yielding
                            • Threads and processes
                            • Barrier synchronization
                            • Mutexes and semaphores
                            • Java synchronized
                            • Signal and wait
                            • Lockless structures

                            • HW11: Memory Management

                              Dan Waters, Kefei, and Mike will present on topics of their choice
                              May 12 Case Studies
                              All the world's a...
                              • Scheme: list
                              • Python, TCL, and Perl: string
                              • C: byte
                              • C++, Java, and Smalltalk: object
                              • APL, Excel, and Fortress: equation
                              • Matlab and Fortran: matrix
                              • GLSL: 3D vector
                              • Prolog: logical proposition
                              • CUDA: thread

                              Plus, CS334 Bingo
                              • PLAI 32

                                May 14The Future
                                • Programming for parallelism
                                • Accessible programming
                                • Safety and security
                                • Course evaluations

                                • PL Notes (5/12/09 version)--may be brought to final exam.
                                  • HW12: Conclusions

                                    Final Exam: Wed May 20, 9:30 am in TCL 206


                                    The required course textbook is Krishnamurthi, Programming Languages: Application and Interpretation, ver 2007-04-26. (Download Free PDF) (Buy PDF) (Buy Hardcopy). Not only is it a great text, but because it is available as PDF you can search it, and can paste the examples directly into your programming environment (although I agree with the author's suggestion that you re-type them to force you to read more closely.)

                                    Although it is not required I highly recommend that you buy a copy of Alan Turing: The Enigma by Hodges. It is an easy and exciting read. The biography covers many of the high points of the course in non-technical language as well as introducing you to the most important computer scientist of all time.

                                    Occasional additional required reading, typically in the form of research papers, may be distributed throughout the semester. For many lectures, supplemental reading is recommended that offers an alternative explanation or explores a topic further.

                                    The following are completely optional (that is, unless I assign one of them) recommended reading. Some of these might be good topic sources for your 2-minute presentation. Note that not all of the recommended reading is technical!

                                    1. A. Hodges, Alan Turing: The Enigma, Random House, London, March 1992.

                                    2. J. McCarthy, Recursive functions of symbolic expressions and their computation by machine, Comm. ACM 3, 4 (1960) 184-195.
                                    3. An Introduction to Operational Semantics
                                    4. Benjamin Zorn, Comparing mark-and sweep and stop-and-copy garbage collection, ACM conference on LISP and functional programming, 1990.
                                    5. Jeffrey Dean and Sanjay Ghemawat, MapReduce: Simplified Data Processing on Large Clusters, OSDI'04: Sixth Symposium on Operating System Design and Implementation, San Francisco, CA, December, 2004.

                                    6. Edward Estlin Cummings, Since Feeling Is First, in E. E. Cummings: Complete Poems 1914-1962 p. 291, Ed. George J. Firmage, New York: Liveright, 1991.

                                    7. Rob Pike, Sean Dorward, Robert Griesemer, Sean Quinlan, Interpreting the Data: Parallel Analysis with Sawzall, Scientific Programming Journal Special Issue on Grids and Worldwide Computing Programming Models and Infrastructure 13:4, pp. 227-298.

                                    8. The Java HotSpot Virtual Machine, Sun Microsystems.
                                    9. Steve M. Blackburn, Richard Jones, K. S. McKinley, J. Eliot B. Moss, Beltway: Getting Around Garbage Collection Gridlock, ACM SIGPLAN Conference on Programming Language Design and Implementation,2002.

                                    10. E. D. Berger, B. G. Zorn, and K. S. McKinley, Composing High-Performance Memory Allocators , ACM SIGPLAN Conference on Programming Language Design and Implementation,2001.

                                    11. J. Backus, Can programming be liberated from the von Neuman style?, Comm. ACM 21, 8 (1978) 613-641. (large file)
                                    12. R. Harper, Introduction to Standard ML, Report ECS-LFCS-86-14, Dept. Computer Science, Univ. Edinburgh, 1989. (Link is to updated web version.)
                                    13. B. Kernighan, Why Pascal is Not My Favorite Programming Language, Bell Labs CSTR 100, July 1981.
                                    14. A. Koenig, An anecdote about ML type inference, USENIX Symposium on Very High Level Languages,1994.
                                    15. Westley Weimer and George C. Necula Finding and Preventing Run-Time Error Handling Mistakes. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages and Applications, 2004.
                                    16. N. Wirth, Program development by stepwise refinement, Communications of the ACM, 14, 4 (1971) 221--227.
                                    17. D. Parnas, On the criteria to be used in decomposing systems into modules, Communications of the ACM, 15, 12 (1972) 1053-1058.
                                    18. Guy Steele, Growing a Language, Invited talk at OOPSLA 1998.

                                    19. D. Ingalls, Design principles behind Smalltalk, BYTE Special Issue on Smalltalk, August 1981. (Scanned by Dwight Hughes.)
                                    20. 15 Years Ago in BYTE: The Smalltalk Environment by Larry Tessler, BYTE, August 1996.
                                    21. W.R. Cook, Interfaces and specifications for the Smalltalk-80 collection classes,.Proc ACM Conf. Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '92). ACM SIGPLAN Notices ,Vol. 27, No. 10 (Oct. 1992), Pages 1-15.
                                    22. Henry McGilton and James Gosling, The Java Language Environment: A White Paper, 1996. (The most relevent sections are Chapters 1-2 and 4-6).

                                    23. Security readings:

                                    This is the course page for CS334: Principles of Programming Languages at Williams College, S09. Previous years: S08,S07, S05, S04, S03, S02

                                    Suggested Presentation Topics

                                    A great presentation topic is one of the recommended reading papers above, or follow-up on something shown in class. If you prefer less time investment, you can do a good presentation from an encylopedia article, but be careful to check your facts with primary sources. Here are some obvious choices for topics:
                                    1. Technical Topics (some are covered in lectures)
                                      1. Monads
                                      2. Hygenic macros
                                      3. Turing machines
                                      4. Formal expressivity
                                      5. Modules
                                      6. Template metaprogramming
                                      7. C's GOTO and scope
                                      8. Reactive languages
                                      9. Denotational semantics
                                      10. Referential transparency
                                      11. Array subtyping in Java
                                      12. Stop-and-copy GC
                                      13. Generational GC
                                    2. Languages
                                      1. Haskell
                                      2. Matlab
                                      3. Latex/Tex
                                      4. Prolog
                                      5. CUDA
                                      6. Lisp
                                      7. Postscript/PDF
                                      8. Smalltalk
                                      9. AWK
                                      10. Ada
                                      11. Make
                                      12. Forth
                                      13. APL
                                      14. Algol
                                      15. Fortress
                                      16. X10
                                      17. BASIC
                                      18. Fortran
                                      19. Cobol
                                      20. Tcl
                                    3. People
                                      1. Alan Turing
                                      2. Alonzo Church
                                      3. John von Neumann
                                      4. Ada Lovelace
                                      5. Guy Steele
                                      6. Alan Perlis
                                      7. Haskell Curry
                                      8. Fran Allen
                                      9. Niklaus Wirth
                                      10. Guido van Rossum
                                      11. Brian Kernighan
                                      12. Barbara Liskov