Compiler Book Recommendations

Can anyone recommend good compiler books that are more recent than the dragon book? There have been lots of advancements in compiler technology since that book was written. One of my frustrations with traditional compiler books is that they do not do a good job of explaining how to parse languages where white space is significant, like Haskell, Python, YAML, etc., or how to recover from errors. I’m interested in topics like Parsing Expression Grammars (packrat/pika/squirrel), parser combinators, Language Server Protocol, Hindley-Milner type systems, type inference, dependent types, tail call elimination, lambda calculus, category theory, etc. The focus would be how to implement compilers for functional languages like Haskell, Idris 2, Purescript, Flix, Scheme, F*, Lean, Unison, etc., rather than more traditional imperative or object-oriented languages.

2 Likes

Well, for Lisp/Scheme specifically, I can recommend Lisp in Small Pieces by Christian Queinnec. It dates back to the mid-90s but it still offers important lessons IMHO. Particularly the continuity between interpreters and compilers (which is an important concept in Truffle/Graal, for example).

For the other stuff you mentioned, I’m all ears :slight_smile:

1 Like

What got me thinking about the limitations of the dragon book was watching a YouTube video where Andres Hejlsberg explains the book is over 30 years old, and we don’t even do it that way anymore. Here’s a link to the video: Anders Hejlsberg on compilers. I found it quite interesting.

The university compiler courses I have seen essentially just repackage what is in that old book. It makes me wish Andres wrote a book about how he uses functional data structures to implement real compilers now. If anyone knows him, I would love to have him present at a Strumenta meetup to talk about it.

For an in depth read on type systems “Types and Programming Languages” by Benjamin C. Pierce is pretty good.

A good article, by the author (Bob Nystrom), pointing to a book. Crafting “Crafting Interpreters” – journal.stuffwithstuff.com