3 ms·
This repo is great! Always nice to see an end-to-end compiler example for a real programming language. Unfortunately, real programming languages are very compl
by obi1kenobi 4y ago
This repo is great! Always nice to see an end-to-end compiler example for a real programming language.
Unfortunately, real programming languages are very complex, so writing compilers often gets bogged down in complexity, edge cases, and "mop up" work. Often it can be better to learn on a simpler language where you can afford more focus and more depth before things get too complex.
Most "write a compiler" tutorials end up focusing predominantly on having a working compiler rather than one that produces well-optimized code. I decided to write a blog series dedicated specifically to implementing compiler optimizations for a simpler programming language -- the one from last year's Advent of Code day 23.
It's called Compiler Adventures and every episode in the series describes and implements a new optimization, like no-op elimination (ep. 1), constant propagation (ep. 2), value numbering (ep. 3), value range analysis (ep. 4, coming out in a few days), etc.
Check it out here: https://predr.ag/blog/compiler-adventures-part1-no-op-instructions/ https://predr.ag/blog/compiler-adventures-part1-no-op-instru...
- agumonkey 4y agonice idea, very nice
- williamcotton 4y agoI love this series and I am very much looking forward to episode 4 (and more)!
- WalterBright 4y agoWriting compilers is actually rather easy. The hard part is dealing with other programs. For example, last week I finally tracked a bug down to the documentation on how the function ABI worked was simply wrong.