
Compiler design in C
by Allen I. Holub · first published 1990
28mentions
11recommended by
18HN commenters
2011–2026first – last mentioned
61% recommend28% neutral11% critical
Why HN recommends it
Hands-on walkthrough of building a C compiler from the ground up, including its own lexer and parser tools, with well-written code that readers learn from. Suits those who want to see how compilers are built in C.
Common criticism: Some find the compiler it produces fairly limited and the tool-building detour long.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.







For anyone wanting to read about C as intermediate language, Compiler Design in C (1990) http://www.amazon.com/Compiler-Design-C-Prentice-Hall-softwa... EDIT: Adding some extra remarks I think might also be interesting to share. Another approach, that I really like, is to output…
on “C as an intermediate language (2012)” ↗And if I were to start writing a compiler today, I would certainly start with Holub's book Compiler Design in C.
on “C++ Grandmaster Certification” ↗…full C compiler with a recursive descent approach (no flex/lex or bison/yacc). I have some experience augmenting this compiler, so I can vouch for the book's ability to clearly convey their design. Compiler Design in C, by Allen Holub (http://www.holub.com/software/compiler.design.in.c.html). Downloadable PDF at that link as well. A book from 1990 in which Holub constructs his own version of lex and yacc, and then…
on “How I wrote a self-hosting C compiler in 40 days” ↗Anyone that wants to write C compilers has two good books for it. "A Retargetable C Compiler: Design and Implementation", from David R. Hanson and Christopher W. Fraser "Compiler Design in C", from by Allen I. Holub A bit old, but there are not significant changes to C since they were written, other than optimizers taking advantage of UB.
on “Writing a C Compiler, Part 1” ↗10 days ago, I finished the first book and now I can't wait to get in my hands this second book about compilers! I'm currently reading "Compiler Design in C" by Allen I. Holub, https://holub.com/compiler/, and so far I like it. But to use Go in place of C would be a nice alternative as well! I can't wait to read the new book.
on “The sequel to Writing an Interpreter in Go is coming this summer” ↗Alan Holub's 'Compiler Design in C' is not mentioned in the books. Holub's book had well-written code. I had learned a lot from his code.
on “Resources for Amateur Compiler Writers” ↗…One of the books that I endless read multiple times, is nowadays available for free, and eventually interesting for your reading collection, even though it is about the compiler part not debugging. "Compiler Design in C" https://holub.com/compiler/ It is a bit oldie, but maybe interesting.
on “Show HN: I spent 6 months building a new C debugger as a 17-year-old” ↗It was a product of its time I guess, much better ones from similar vintage, The Tiger book (with C, Standard ML, and Java variants) https://www.cs.princeton.edu/~appel/modern/ Compiler Design in C (freely available nowadays, beware this is between K&R C and C89) https://holub.com/compiler/ lcc, A Retargetable Compiler for ANSI C https://drh.github.io/lcc/ Or if one wants to go with more clever…
on “Want to Write a Compiler? Just Read These Two Papers (2008)” ↗…and Tools) by Aho, Sethi and Ullman is on every computer scientist's bookshelf for good reason -- it tells you everything you need to know about how the languages you use are built. I also like Holub's "Compiler Design in C," though it's a lot more hands-on. For understanding OSes, I recommend "The Magic Garden Explained," and Bach's "Design of the UNIX Operating System." Outdated, perhaps, but outstanding in their clarity.…
on “Book recommendation to learn basics of Comp Sci?” ↗A fantastic book along these lines is Allen Holub's "Compiler Design in C". It's old (1990) and out of print, but you can get the PDF for free from Holub's site [1]. Over the course of the book, a C compiler is developed. To handle lexical analysis and parsing, tools similar…
on “C Compiler from Scratch” ↗Allen Holub's book "Compiler Design in C" is excellent. The book is out of print, but you can get it as a free PDF from Holub's site: http://www.holub.com/software/compiler.design.in.c.html Over the course of the book you implement compiler…
on “Ask HN: Recommend an introductory course on compilers” ↗"Enough rope to shoot yourself in the foot - rules for C and C++ programmers" by Alan C Holub. And "Compiler design in C", also by him
on “Ask HN: What is the best programming book you've read?” ↗Although it is older than a fair number of HN readers, a great book from 1990 on compilers is Allen Holub's "Compiler Design in C". It's long out of print but there is a free PDF on Holub's website [1]. The book covers the usual theory and then puts it to use to develop tools for writing compilers (e.g., lexical analyzer generators…
on “Create Your Own Compiler: A step-by-step interactive tutorial” ↗…intermediate book between K&R and "Expert C Programming". I never see Holub mentioned much by other C programmers but I think his books are awesome. He actually also has a really good compiler book called "Compiler Design in C" that showed how to build a C compiler from the ground up - with a lot of practical details I never really see in other books in that area. He even had a cool curses implementation to go along with it…
on “Obfuscated C Code Contest 2006. Please explain sykes2.c” ↗If besides the author's book (good work), you want to delve into how others approach the subject, check - Retargetable C Compiler, A: Design and Implementation - Compiler Design in C
on “Writing a C Compiler is a book” ↗