r/Compilers • u/Conscious-Ease-6729 • Nov 01 '23
Best Book to learn compiler from beginning
Hello,
Can any one recommend the best book for learning compiler from beginning to proficiency? Adding a link to materials will be very helpful.
49
Upvotes
13
u/mttd Nov 02 '23 edited Nov 02 '23
I'd start with "Engineering a Compiler" by Keith Cooper and Linda Torczon (Third Edition has been published last year).
For more recommended resources see previous discussions on the same topic:
Incidentally, if we were still in the 1990s I'd say to not bother with the Dragon Book as it's an obsolete, mediocre intro to the basics of parsing theory and not a good example of a compiler book. In 2023 it doesn't deserve a further comment.
There's plenty of better resources that are more worthy of your time (see above)--I'd particularly recommend "SSA-based Compiler Design" (https://link.springer.com/book/9783030805142) as follow-up text or "Static Program Analysis" by Anders Møller and Michael I. Schwartzbach (https://cs.au.dk/~amoeller/spa/spa.pdf) for a general background in program analysis (which may come in handy).
6
u/WasASailorThen Nov 02 '23
If you're studying on your own, Crafting Interpreters is hard to beat. If you're going to use LLVM as a code base (a wise choice), I like Getting Started with LLVM Core Libraries. If you're taking a course, the Dragon Book or Andrew Appel are good choices.
3
u/drinkcoffeeandcode Nov 02 '23 edited Nov 02 '23
The dragon book is great, if not a bit dated, but if you’re serious about compilers, you pretty much have to have it in your collection.
I really like “compiler construction principles and practices” by Kenneth Louden. It covers pretty much everything the dragon book does, but uses a more modern C. It also covers things like functional programming languages, object oriented languages, and quite a bit on types.
Introduction to compiler construction by Thomas parsons is another good one, but is a bit heavier on the YACC
I’ve heard good things about “modern compiler something or other” by Appel though I’ve only thumbed through a pre-print of the Java version
You may think I was joking about being serious about compilers and having a collection of books on them, but it’s one of those subjects where it’s really best to approach it by gathering as many different resources as you can and read them all. It is such a multi-faceted subject that you can go as deep or shallow as you like with. But to really understand it your going to have to read ALOT, often the same material explained different ways before you truly understand it, that was my experience at least.
1
u/lightmatter501 Nov 01 '23
The dragon book. Probably 70% of people here learned from it.
https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811?nodl=1&dplnkId=98e1221b-7b47-4f5f-9fff-428be2828b91
28
u/[deleted] Nov 01 '23
[removed] — view removed comment