This class is for more experienced programmers who like learning new
things and being challenged. Knowledge of Python programming
basics is assumed. No background in compilers is required although
knowledge of fundamental programming language concepts (e.g., type
systems, functions, objects, scoping rules,etc.) is strongly
Date: March 20-24, 2017.
[ Register | More Information |FAQ]
- A printed copy of the course notes.
- Breakfast and lunch at local restaurants
Write a Compiler
[5 days] Come to Chicago and shatter your
brain by writing a compiler
for a programming language! Why? Because it's fun and you'll learn a lot, that's why.
In this workshop, participants will be partake in an intense guided coding
project where you will create your own programming language, write
a compiler for it, and have your compiler emit working executable code
using LLVM. If you've ever wanted to take a compilers course or
you're just looking for a project that's a bit more involved than
reading a CSV file, then this is the course for you.
Major topics include:
- Regular expressions and text manipulation
- Parsing and parser generators
- Syntax directed translation
- Abstract syntax trees
- Type systems and type checking.
- Control-flow analysis
- Code generation
Almost all of this course is spent coding on a project. Lecture
slides are given as necessary to discuss background material prior
to different project sections.
Compilers is often considered a capstone course for computer science
majors. There is a reason for that--it touches almost every topic
ranging from mathematical theory to computer architecture. Here are
some practical things that you'll get out of taking this course:
- Text manipulation and parsing skills. These can
be applied to a variety of problems such as data munging, scraping, protocol
implementation and more.
- Complex data structure manipulation. Writing a compiler involves
a vast array of data structures beyond your basic list or map. You'll
build trees and directed graphs. You'll need to write code that
navigates through those data structures. Managing the complexity
is a challenge and you'll likely get ideas for how you might do it
in other contexts (e.g., machine learning, networking, etc.).
- Testing. A compiler is one of the most complicated programs
you will ever write, consisting of a series of interlocking components
that interact in non-trivial ways. Figuring out how to test it is
hugely problematic. As such, you'll be exploring different facets of unit
testing, integration testing, assertions, contracts and more. These
skills will be useful in all of your future software development.
- Object Oriented Programming. One approach for managing the
complexity in a compiler project is to utilize different object
oriented programming techniques and design patterns. Although OO is
not the main focus, you will implement code involving a variety of
classes and advanced programming techniques involving classes. This
may include inheritance, multiple inheritance, decorators, and metaclasses.
Seeing these features used in practice will give you insight into how
large frameworks operate and may give you ideas on how they could be
applied to your own code in future projects.
- Programming Language Semantics. How does your favorite
programming language actually work? No, I mean do you REALLY
understand how it works? In order to write a compiler, you have to
wrap your brain around a lot of important, often esoteric,
under-the-hood details. For example, the underlying type system,
memory management, evaluation rules, call stacks, and more. After
you're done writing a compiler, you'll have a much greater awareness
of how everything works and this has all sorts of side-benefits. For
example, you'll be able to do more informed debugging and performance
- Python Since you'll be writing a compiler in Python,
you'll see a lot of advanced Python features in action, being used in
a practical context. If looking for an interesting way to take
your Python coding skills to the next level, writing a compiler
certainly won't disappoint.
- Deeper Computing Knowledge. The next time you're at a party
and two people are about to get into a heated fisticuffs battle over
tail-call optimization, you'll be able to step in and break up an ugly
scene. Why? Because you took compilers, that's why. You don't need
to be a computer science major to take compilers, but when you're done,
you might be mistaken for one.
Are You Crazy?
Writing a compiler in only 5 days? Is it even possible? To be sure,
compilers is often regarded as one of the most difficult CS courses
that one can take. If you take it at a University, you'll probably
get a professor who will take you through the infamous Dragon Book,
spend a lot of time doing mathematical proofs (e.g., deriving the
LALR(1) parsing algorithm), and make the focus of the course on
preparing graduate students for future research in programming
languages. I have taught that class. This is NOT that class.
Compiler builders working on the last stages of code generation
Instead, this is a compilers course aimed at practioners. As such,
the main focus is on coding and software development. Yes, you will
learn about important core compiler concepts such as regular
expressions, context free grammars, type systems, and programming
language semantics. However, instead of doing mathematical proofs
involving parsing theory, we'll focus on how you would actually go
about implementing a parser and doing things such as writing unit
tests for it. These are the sorts of hard problems that you can more
immediately apply to your own work afterwards.
To be sure, you will write a lot of code in this course. The course
runs for more than 40 hours over five days. The final completed
project consists of approximately 3000-4000 lines of Python and is
every bit as involved as the project you typically find in a
college-level compilers course for computer science majors.
About the Instructor
This course is conducted by David Beazley, author of the Python
Essential Reference (Addison-Wesley) and Python Cookbook (O'Reilly
Media). Dave has a Ph.D in Computer Science and spent seven years
teaching as an assistant professor at the University of Chicago where
he previously taught a compiler design and implementation course.
Dave is also the creator of
SWIG (a C++ compiler for building
scripting language extensions)
and PLY (Python
versions of the Lex and Yacc compiler construction tools).