The tl;dr of this post is: write a Scheme interpreter and then read the LLVM tutorial. Nothing wrong with this, but you won’t be a “wizard” at the end.
My personal recommendation is reading Engineering a Compiler by Cooper/Torczon or Modern Compiler Implementation in ML by Appel. Since this post has a section on privilege, I will note that if you can not afford the ludicrous cost of textbooks, you can get free copies of any textbook from Library Genesis.
Once you have moved past the basics you can move on to Optimizing Compilers for Modern Architectures by Allen and Kennedy, which will skip all pretense of introduction and jump straight into advanced optimizations.
If you are writing a compiler for a high-level language, you will also need to write a runtime system. The GC will likely be the most complicated part of your RTS. For info on writing a GC, The GC Handbook by Jones is the gold standard. One of my favorite technical books.
I do not recommend working on other peoples code (aka the Open Source part of this blog post). An established project will have already taken care of the fundamentals and much of the low-hanging fruit. You, as a wizard-in-training, need the experience of writing this yourself.
Yea, this is kind of a weird post. It says to learn regexes, but the only place you’ll use a regex in your compiler is in your lexer (unless you use call stack regexes in your interprocedural call optimizations!). And if regexes were worth mentioning, why not context-free grammars, which you will spend a lot more time with when writing your parser?
I agree that Modern Compiler Implementation by Appel is a nice intro book. I used the Java version although the compiler I worked on for my intro course was in OCaml.
Agreed. I also suggest taking a look at http://c9x.me/compile/bib/ if you want a list of references.
Engineering a Compiler by Cooper/Torczon or Modern Compiler Implementation in ML by Appel
FYI: These are both in Safari Books Online if you happen to have a subscription.
I second the recommendation for Appel’s book. It’s some years out of date compared to the latest advancements in type systems, but it was one of the first to address then-modern type systems, and I’m not aware of a newer book that does it better.
Do you have a book recommendation for more modern type system implementation that isn’t a compiler intro? If someone, for example, starts with Appel and wants to move forward from there?
Types and Programming Languages (TAPL) by Pierce. There is also a follow-up book, Advanced TAPL
Those. :) But I haven’t made it through them, other than a preliminary read of just the exciting promises in each chapter. So I don’t feel right recommending them.
Do these recommendations also apply to FP langs?
My current recommendation for a compiler text book is Crafting a Compiler by Fischer, Cytron and LeBlanc. Easy to read, and they don’t get too crazy into theory.