3 ms·
Anyone know a good resource for getting started writing a compiler? I'm not trying to write a new LLVM, but being a "software engineer" writing web-based APIs f
by imwally 8mo ago
Anyone know a good resource for getting started writing a compiler? I'm not trying to write a new LLVM, but being a "software engineer" writing web-based APIs for a living is leaving me wanting more.
- jazzpush2 8mo agohttps://craftinginterpreters.com/ https://craftinginterpreters.com/
- jandrese 8mo agoTraditionally you would start with the Dragon Book[1]. Another starting point is reading the documentation for Yacc (aka Bison) and Lex. [1] https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniq...
- compiler-guy 8mo agoThe dragon book is a classic, and was a terrific resource thirty and forty years ago. Today there are many far better resources. Several listed adjacent to this one. It’s focused on theory and very heavy on parsing. All of that is fine, but not especially useful for the hobbies.
- prydt 8mo agoI would highly recommend Wirth's Compiler Construction. Great, short book with a lot to say.
- macintux 8mo agoI've favorited a fair number of compiler discussions here. Some you may find useful, either for the linked content or the discussions therein: - Writing a Compiler is Surprisingly Easy - https://news.ycombinator.com/item?id=38182461 https://news.ycombinator.com/item?id=38182461 - Write your own retro compiler - https://news.ycombinator.com/item?id=38591662 https://news.ycombinator.com/item?id=38591662 - Compiling a Lisp - https://news.ycombinator.com/item?id=39216904 https://news.ycombinator.com/item?id=39216904 - Writing a C Compiler - https://news.ycombinator.com/item?id=41227716 https://news.ycombinator.com/item?id=41227716 - Compilers: Incrementally and Extensibly - https://news.ycombinator.com/item?id=43593088 https://news.ycombinator.com/item?id=43593088 - Working through 'Writing a C Compiler' - https://news.ycombinator.com/item?id=44541565 https://news.ycombinator.com/item?id=44541565 - Build a Compiler in Five Projects - https://news.ycombinator.com/item?id=46031220 https://news.ycombinator.com/item?id=46031220 Personally I found Crafting Interpreters to be a terrific introduction to the key concepts: https://craftinginterpreters.com https://craftinginterpreters.com (But I'm just a kibitzer, I've never written anything more serious than a DSL in Perl.)
- ratzkewatzke 8mo agoThere are several good suggestions in this thread already, but I think Nora Sandler's newish book (https://www.amazon.com/Writing-Compiler-Programming-Language-Scratch/dp/1718500424 https://www.amazon.com/Writing-Compiler-Programming-Language...) is approachable and fun if you want a less academic approach.
- piinbinary 8mo agoI am currently going through that book. I recommend it with one caveat: you'll need to have written some interpreters before (Crafting Interpreters is a perfect starting point) because it expects you to already know some things like to how write a simple recursive decent parser.