
Modern compiler implementation in C
by Andrew W. Appel, Maia Ginsburg · first published 2004
13mentions
8recommended by
12HN commenters
2010–2024first – last mentioned
67% recommend25% neutral8% critical
Why HN recommends it
A practical compiler-construction textbook, often picked over the Dragon Book for its balance of lexing, parsing, optimization and code generation. Suited to readers who want to build a compiler themselves.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.







…textbook distributor for the equivalent of about $30. For anyone interested in other books on compiler construction, I would recommend these: - "The Basics of Compiler Design" by Torben Mogensen - "Modern Compiler Implementation in C" by Andrew Appel (ML and Java versions available too) - "Modern Compiler Design" by Grune, Bal et al. The Dragon Book is obviously infamous for this topic, but I would recommend covering at least two…
on “Ask HN: What's the best computer science book you've read recently?” ↗Are you looking for information on writing compilers as well, or just language design? If the former, I suggest Modern Compiler Implementation in (C|Java|ML) by Andrew Appel, as well as the de facto `Dragon Book' (Compilers, Principles, Techniques and Tools).
on “Ask HN: Resources for creating a programming language” ↗After grinding through a bunch of compiler books I have to mention "Modern Compiler Implementation in C - Andrew A. Appel": http://www.amazon.co.uk/dp/0521607655 as one that stands out. For LALR Parsers and DFA scanners and the like, I found the original Dragon Book http://www.amazon.co.uk/dp/B00EKYURHS…
on “Self hosted C – breakdown” ↗I’m not sure I’d agree with the Dragon Book recommendation. I think a better starting point might be Appel’s Modern Compiler Implementation in C/Java/ML.
on “A 28-year-old with no degree becomes a must read on the economy” ↗Try the Tiger Book instead (a.k.a. 'Modern compiler implementation in C', or there are Java or ML versions if those are more to your taste). It has a better balance: more to the point treatment of lexing and parsing, leaving more space for a more comprehensive treatment of…
on “A Tourist’s Guide to the LLVM Source Code” ↗Modern Compiler Implementation in C
on “How I wrote a self-hosting C compiler in 40 days” ↗…operations, it is often based on Pratt parsers (at least the official C++ version[1]), but there's a C version on github [2]. In my opinion, you could get pretty far by reading the "Compiler design in C" or "Modern compiler implementation in C" up to the point of optimization and then applying the code generation from kaleidoscope tutorials. LLVM takes care of many optimizations. [1] http://llvm.org/docs/tutorial/LangImpl1.html [2] https://github.com/benbjohnson/llvm-c-kaleidoscope
on “Compiler Design in C” ↗For anyone that wants to learn about optimizations in AOT compiled ML languages, have a look at: "The Implementation of Functional Programming Languages" "Compiling with Continuations" "Modern Compiler Implementation in ..." (C, Java and ML variants) Although oriented towards Lisp, "Lisp in small pieces" is a classical book as well, with many optimizations like inlining of lambda calls across multiple call levels.
on “Rust: Zero-Cost Abstraction in Action” ↗Get Modern Compiler Implementation in C [0] (with Java and ML versions also available),or the Kaleidoscope LLVM tutorial [1], and do the whole thing in 2 weeks, as starting point. [0] - https://www.cs.princeton.edu/~appel/modern/c/ [1] -…
on “Beating the Compiler” ↗…L. Hennessy, David A. Patterson #27 The Elements of Computing Systems - Noam Nisan, Shimon Schocken #28 The ACE Programmer's Guide - Stephen D. Huston, James C. E. Johnson, Umar Syyid #29 Modern Compiler Implementation in C - Andrew W. Appel, Maia Ginsburg #30 Algorithms + Data Structures - Niklaus Wirth Caveat: I am not a compiler writer, though I have read many of these books. Still, my point stands, a good search…
on “The most mentioned books on Stack Overflow” ↗Well, it was basically the only book out at that time. I remember a few others in the 1990s - Compiler Design in C; Holub, and later after I graduated Modern Compiler Implementation in C; Appel). Hey something cool I found while googling - Holub's book is available as a free download from the author! (https://holub.com/compiler/) The Dragon Book has flaws but it is also the case where…
on “Turing Award goes to Aho and Ullman” ↗Near the end the author looks towards the future and writing a small compiler. He mentions "Modern compiler implementation in C," and I was aghast. That was one of the worst textbooks I ever had to suffer through.
on “Going back to C” ↗The book Modern Compiler Implementation in C has a very functional style, written in 1997
on “On programming without malloc” ↗