TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Best book about compilers?

10 pointsby pipualmost 8 years ago
I would like to grab a book on compilers but am not sure which one to choose.<p>The Dragon book (Compilers: Principles, Techniques, and Tools) is the one that gets recommended everywhere but that doesn&#x27;t always mean it&#x27;s the best. I find that many people recommend books they&#x27;ve actually not read and&#x2F;or they haven&#x27;t read anything else on the subject which makes it a bit tough to say the one they&#x27;re familiar with is the best.<p>Some have said the dragon book is unbalanced in content and for instance Modern Compiler Implementation in ML is better in that.<p>What is your opinion? Can you recommend some book over another one?<p>Also: I&#x27;m not sure if a 800 page brick is the best to get yourself familiar with ... anything(?). I&#x27;m most certainly sure the book I&#x27;m looking for doesn&#x27;t have to cover every tiny little detail that could be useful to know every 0.000001 % of time.<p>Thanks!

4 comments

kjksfalmost 8 years ago
I doubt people who actually do write compilers would get much of use of any book out there.<p>There are 2 main tasks a compiler does:<p>* parsing * optimized code generation<p>While nominally parsing is covered by books and there&#x27;s loads of theory on it, production compilers (gcc, clang, Go, swift) pretty much always end up with hand-written recursive-descent parser, which are a lot work but their structure is rather simple.<p>Code generation is universally done by converting to SSA and then writing optimization passes on top of that. Again, lots of work and lots of optimization rules, but nothing earth shattering conceptually. Read up on SSA and study existing code like <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;tree&#x2F;master&#x2F;src&#x2F;cmd&#x2F;compile&#x2F;internal&#x2F;ssa" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;tree&#x2F;master&#x2F;src&#x2F;cmd&#x2F;compile&#x2F;int...</a> for real-life optimization.<p>Then there&#x27;s linker stuff like generating pe&#x2F;elf&#x2F;mach-o executables, generating symbols etc., which isn&#x27;t covered in books but there&#x27;s documentation on-line on all those subjects and you can study existing code like <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;tree&#x2F;master&#x2F;src&#x2F;cmd&#x2F;link&#x2F;internal&#x2F;ld" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;tree&#x2F;master&#x2F;src&#x2F;cmd&#x2F;link&#x2F;intern...</a>
joe_loseralmost 8 years ago
The book &quot;Engineering a Compiler&quot; (<a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Engineering-Compiler-Second-Keith-Cooper&#x2F;dp&#x2F;012088478X" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Engineering-Compiler-Second-Keith-Coo...</a>) is a good resource and reference; I keep it on my desk at work. Like other compiler books, it falls short in meeting all practical application purposes and does great with theory. Ideally, this book should be combined with looking at modern compiler implementations.
brudgersalmost 8 years ago
I&#x27;m not sure it is the best, but it is clearly an alternative to the Dragon book.<p><a href="https:&#x2F;&#x2F;compilers.iecc.com&#x2F;crenshaw&#x2F;" rel="nofollow">https:&#x2F;&#x2F;compilers.iecc.com&#x2F;crenshaw&#x2F;</a>
zerralmost 8 years ago
Is the dragon book really recommended nowadays? I don&#x27;t think so, especially for starters.
评论 #14892488 未加载