Thursday, February 2, 2017

Writing a Compilers Textbook

To my surprise, I am in the final steps of writing a textbook!  You can see a sample chapter today at

The effort began in the fall of 2016, as I was putting together my materials for CSE 40243, our undergraduate class in Compilers and Language Design.  This class focuses on the challenges of engineering a working language: students implement a working compiler that translates a C-like language into X86 assembly.

While there are a variety of solid textbooks that are great for a graduate course in compiler theory and optimization, none quite had the flavor I was looking for.  Nearly every CS grad needs to write a parser, evaluator, or translator for some kind of little language in their career, but relatively few need to dig deeply into assembly language optimization.  So, I wanted to focus on language design choices and show that simple languages are not hard to implement.

I began to combine my handwritten chalkboard notes and some sample code into a LaTeX document, and the next thing you know, I have seven chapters written.  I expect to finalize everything in the spring 2017 semester.

What has made it relatively easy so far is that my compiler automatically generates many of the figures and code examples automatically, so relatively few things have to be drawn by hand.  For example, this sample AST is produced automatically by the compiler emitting Graphviz DOT code from the internal representation.  Neat, eh?

Following the example of Remzi and Andrea Arpaci-Dusseau with OSTEP the book will be made available for free online in PDF form, and also in an inexpensive hardcover edition printed on-demand.

Stay tuned for the release later in 2017...


  1. This comment has been removed by the author.

  2. Proffesor Thain,

    I'd really like to sincerely thank you for your work on the book as well as making it freely available to the public, including self-learners like me.

    To me, one big advantage of your text book over other textbooks (payed and free) is it gives many practical details necesary to actually make a working compiler, in contrast to focusing solely on theoretical aspects of compilation.

  3. Fantastic work.. I appreciate it. The travelers around the world who wish to travel to Azerbaijan need to apply for azerbaijan visa for us citizen through e visa application. Get your visa with super fast processing with 24/7 assistance.

  4. Your post is truly captivating! It effortlessly navigates through the intricacies of thought, inviting readers on a profound journey of self-reflection and enlightenment. Your prose exudes a rare combination of elegance and lucidity, guiding us through the labyrinth of ideas with grace. Thank you for sharing your profound insights.