This class is for more experienced programmers who'd like to expand
their knowledge by facing a good challenge. Knowledge of Python
programming basics is assumed. No background in compilers is required
although awareness of common programming language concepts (e.g., type
systems, functions, classes, scoping rules,etc.) is strongly
Date: January 15-19, 2018.
[ Register | More Information |FAQ]
- 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. In this workshop, you'll undertake the
same intense coding project typically given to graduate computer
science students in their first-year compilers course. Major topics
- 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
By the end of the course, you will be able to take a small language
(based on Go) and have it compile to executable programs via LLVM.
The resulting code will have performance comparable to programs written in C.
You'll also see how to make a Just-In-Time (JIT) compiler.
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 many 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 never look at a programming
language in the same way--you'll have a much greater awareness of everything.
- 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).