Compilers

spring 2025

0. Intro & setup

Motivation

Why study compilers? This question is worth asking, since compilers are non-trivial contraptions and most of us probably won’t work directly on one of them during our careers.

While curiosity is always a good reason, there are practical reasons too:

Course philosophy

This course aims to be straightforward, practical and hands-on. It typically presents one good way of accomplishing a task, and then asks you to try it in practice.

This means that, due to limited time, some theoretical breadth and depth has been sacrificed. If you’re looking for more, there are many great books on compilers.

The text has some green links. These reveal optional, non-essential content that expands upon or contextualizes things.

Project setup

While you can complete the course project in any language you like, our examples and instructions are for Python.

If you’re using Python, you can download the project template and follow the instructions in README.md to set it up. There are additional ntes for Mac and Windows users.

If you’d prefer to use a different language, see the alternative project setup.

Submitting your project

‼️ Test Gadget, the project’s automated testing and grading system, will be made available on the last week of January.

To submit your completed project, run ./test-gadget.py submit.

Click here for details about this.

Test Gadget does not replace your own testing. Test Gadget runs end-to-end tests, which start to pass only after you’ve completed most of the project. Local unit testing along the way is highly recommended.

Additional instructions for MacOS and Windows

You can get pretty far with just MacOS or Windows, but near the end of the project you need to generate machine code for x86-64 Linux and test it. While in principle you could test only with Test Gadget, that would be very slow and extremely inflexible.

There are several ways to use an x86-64 Linux environment while developing on MacOS or Windows. Here are instructions for a few of them.

Alternative project setup

If you want to write your compiler in a language other than Python, you are very welcome to do so, but you need to replicate parts of the Python project template yourself. If this interests you, look at these instructions.