Programming Language Concepts


The book Programming Language Concepts (PLC) covers basic concepts such as abstract syntax, interpretation, stack machines, compilation, type checking, garbage collection, and real machine code, as well as the more advanced topics on polymorphic types, type inference using unification, co- and contravariant types, continuations, and backwards code generation with on-the-fly peephole optimization. The book uses a functional programming language (F#) as metalanguage to present all concepts and examples, and thus has an operational flavour, enabling practical experiments and exercises.

Programming Language Concepts covers practical construction of lexers and parsers, but not regular expressions, automata and grammars, which are well covered elsewhere. It discusses the design and technology of Java and C# to strengthen students' understanding of these widely used languages.

The examples present several interpreters and compilers for toy languages, including compilers for a small but usable subset of C, abstract machines, a garbage collector, and ML-style polymorphic type inference. Each chapter has exercises. Complete example source files, lecture slides and other materials are available below.

The second edition includes two new chapters. One describes compilation and type checking of a full functional language, tying together the previous chapters. The other describes how to compile a C subset to real (x86) hardware, as a smooth extension of the previously presented compilers.

Table of contents for the second edition.

Related lectures and example code

ChapterLecture slidesExample code, 1st edExample code, 2nd ed (updated 4 April 2021)
Chapter 1 and Appendix A lecture01.pdf
Chapter 2 lecture02.pdf
Chapter 3 lecture03.pdf and and
Chapter 4 lecture04.pdf and and
Chapter 5 and 6 and section A.11 lecture05.pdf
Chapter 7 lecture06.pdf and and
Chapter 8 lecture07.pdf
Chapter 9 lecture08.pdf
Chapter 10 lecture08.pdf
Chapter 11 lecture09.pdf
Chapter 12 lecture10.pdf and ex13-code.txt and ex13-code.txt
Chapter 13
Chapter 14

Installing FsLex and FsYacc

The FsLex/FsYacc tools for F# belong to the FsProjects github repository at That site does not provide installation instructions.

Bibliographic data, second edition (2017)

P. Sestoft: Programming Language Concepts, Second edition, with a chapter by Niels Hallenberg. Springer Undergraduate Topics in Computer Science. xv + 341 pages. ISBN 978-3-319-60788-7. September 2017. The book's page at Springer. Front matter and back matter are freely available.

Order it from or or straight from Springer.

Errata for the second edition.

Bibliographic data, first edition (2012)

P. Sestoft: Programming Language Concepts, Springer Undergraduate Topics in Computer Science. xiv + 278 pages. ISBN 978-1-4471-4155-6. July 2012. The book's page at Springer. Front matter and back matter is freely available.

Errata for the first edition.

Copyright (c) 2012, 2017 Peter Sestoft ( 2012-06-11, 2021-04-05