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.

Resources for Amateur Compiler Writers

339 pointsby kilodecaabout 4 years ago

16 comments

hardwaregeekabout 4 years ago
This is definitely a backend, machine code focused list. If you&#x27;re writing a compiler to WebAssembly or even the JVM you&#x27;re probably not gonna need a lot of these resources.<p>Indeed I&#x27;d argue that these lists are more for an intermediate compiler writer. Beginner compiler writers don&#x27;t need to know register allocation. They need to understand how to think about language translation, how to write an intermediate representation, how to learn a target language.<p>I&#x27;ve been toying with the idea of writing a post that goes through the thought process of translation. Specifically, how you build states, and invariants. When I write code generation I spend time thinking about the different states the stack could be in, or what invariant I need to keep across this expression (do I need to save a register or global?).<p>One simple but important example of this is realizing that given a proper, sound type checker, your code generator should almost never give errors. By the time you reach code generation you should have proven enough invariants that code generation cannot fail. This isn&#x27;t always true but I&#x27;ve found it to be the case.
评论 #26926416 未加载
评论 #26926633 未加载
评论 #26926429 未加载
评论 #26927927 未加载
评论 #26929946 未加载
评论 #26929309 未加载
estebankabout 4 years ago
A lot of ink is spilled on the details of how to make compilers go from taking text and turn it into fast executables, but I believe that the User Experience of compilers is as important a subject as those, but there&#x27;s very little information about it in the literature, outside of a handful of papers and the design documents of existing compilers that do focus on this.
评论 #26927094 未加载
iTokioabout 4 years ago
By the author of the excellent <a href="https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;" rel="nofollow">https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;</a><p>A lightweight alternative to llvm <a href="https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;doc&#x2F;llvm.html" rel="nofollow">https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;doc&#x2F;llvm.html</a>
UncleEntityabout 4 years ago
<i>The Zephyr Abstract Syntax Description Language</i>, Wang et al.<p>Has been invaluable for creating the AST (and soon the IR nodes)-- though it has been a source of much yak shaving as I&#x27;ve rewritten my asdl generator at least 3 times.<p><i>Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages Book</i>, Terence Parr<p>Pretty java&#x2F;antlr focused but wasn&#x27;t too hard to take the concepts and apply them to a C++ based transpiler I&#x27;ve been slowly poking at.<p><i>Combining Analyses, Combining Optimizations</i>, Cliff Click<p>His thesis and an extension of the linked paper <i>Global Code Motion, Global Value Numbering</i> -- my next step down the rabbit hole...<p><i>Tree Automata Techniques and Applications</i>, Comon et al.<p>Still on the fence on this one vs the iburg&#x2F;burs algorithm, probably be more useful and match better with the way Parr&#x27;s book goes about things.
dmitriidabout 4 years ago
I&#x27;m not an expert by far, but I feel like many people who write compilers or develop languages no longer recommend The Dragon Book as it&#x27;s very outdated.<p>Additionally, the vast majority of compiler books and resources spend too much time on the easiest part of compiling: parsing. It&#x27;s not uncommon for a book or a course dedicate 60-70% of its time to parsing. And leaves nothing to everything else.
评论 #26926525 未加载
评论 #26925889 未加载
评论 #26926241 未加载
评论 #26927060 未加载
jhgbabout 4 years ago
Perhaps Cooper&#x27;s and Torczon&#x27;s &quot;Engineering a Compiler (2nd Edition)&quot; should be among the entries in the &quot;Books&quot; category.
hasitsethabout 4 years ago
Alan Holub&#x27;s &#x27;Compiler Design in C&#x27; is not mentioned in the books. Holub&#x27;s book had well-written code. I had learned a lot from his code.
评论 #26927046 未加载
chandloreabout 4 years ago
Latest versions of the ABI specifications linked in the <i>Machine Specific</i> section<p>ARM: <a href="https:&#x2F;&#x2F;github.com&#x2F;ARM-software&#x2F;abi-aa&#x2F;releases" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ARM-software&#x2F;abi-aa&#x2F;releases</a><p>x86-64: <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;x86-psABIs&#x2F;x86-64-ABI" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;x86-psABIs&#x2F;x86-64-ABI</a> (go to most recent CI job and download artifacts for a compiled PDF)
piinbinaryabout 4 years ago
Are there any good resources for building a runtime and codegen for languages with garbage collection?
评论 #26926556 未加载
评论 #26928212 未加载
phonebucketabout 4 years ago
One thing I find curious: lots of compiler writing seems to be done in Haskell, but I can hardly find any Haskell-based resources for writing compilers.<p>Can anyone here please recommend any such resources?
评论 #26927960 未加载
评论 #26927631 未加载
评论 #26927600 未加载
nethuntersabout 4 years ago
Any similar resources on writing interpreters?<p>Also is there are a technical difference between an interpreter and a VM?
评论 #26925876 未加载
评论 #26926280 未加载
评论 #26928451 未加载
评论 #26925743 未加载
ChicagoDaveabout 4 years ago
I&#x27;ve toyed with compiler stuff for years. My current idea is a fluent&#x2F;piping language. Is there any reference that would help with that?
Rochusabout 4 years ago
There is a more recent edition of &quot;Compilers: Principles, Techniques, and Tools&quot; worth considering: <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Compilers-Principles-Techniques-Tools-2nd-dp-0321486811&#x2F;dp&#x2F;0321486811" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Compilers-Principles-Techniques-Tools...</a>.
ahelwerabout 4 years ago
Does anybody know of good introductory resources on error recovery techniques when writing a parser &amp; interpreter? Bonus points if they use combinators instead of a hand-written parser.
评论 #26927516 未加载
评论 #26928436 未加载
andromeduckabout 4 years ago
Wish there were more resources about or tools for bidirectional parsing.
failwhalesharkabout 4 years ago
ProTips after writing numerous kinds of compilers in university:<p>Recursive descent with backtracking is much easier to construct and maintain for diagnostics than bison&#x2F;flex.<p>Derivative parsing is very interesting.