<story><title>A Compiler Writing Journey</title><url>https://github.com/DoctorWkt/acwj</url></story><parent_chain></parent_chain><comment><author>obi1kenobi</author><text>This repo is great! Always nice to see an end-to-end compiler example for a real programming language.&lt;p&gt;Unfortunately, real programming languages are very complex, so writing compilers often gets bogged down in complexity, edge cases, and &amp;quot;mop up&amp;quot; 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.&lt;p&gt;Most &amp;quot;write a compiler&amp;quot; tutorials end up focusing predominantly on having a &lt;i&gt;working&lt;/i&gt; 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&amp;#x27;s Advent of Code day 23.&lt;p&gt;It&amp;#x27;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.&lt;p&gt;Check it out here: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;predr.ag&amp;#x2F;blog&amp;#x2F;compiler-adventures-part1-no-op-instructions&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;predr.ag&amp;#x2F;blog&amp;#x2F;compiler-adventures-part1-no-op-instru...&lt;/a&gt;</text></comment>
<story><title>A Compiler Writing Journey</title><url>https://github.com/DoctorWkt/acwj</url></story><parent_chain></parent_chain><comment><author>hardwaregeek</author><text>Always nice to see compiler tutorials that extend beyond the common &amp;quot;compile a calculator to a stack machine&amp;quot; genre.&lt;p&gt;I&amp;#x27;ve recently restarted writing a compiler for fun and I&amp;#x27;ve found that the hardest part is actually psychological. There&amp;#x27;s so much stuff I want to put into the compiler and language, so I often end up a little overwhelmed. When that happens it&amp;#x27;s important to just focus on the code and get something done.&lt;p&gt;It&amp;#x27;s also very easy to get myself into a rabbit hole, i.e. I&amp;#x27;m using tree-sitter as my parser, but tree-sitter isn&amp;#x27;t designed to be used as a compiler front end, but hmm what if it was, maybe I should write something that automatically translates tree-sitter grammars to Rust AST definitions so that I don&amp;#x27;t have to manually convert a tree-sitter CST to an AST? Sure, I could go down that path, or I could bite the bullet and manually convert the tree.&lt;p&gt;Compilers are great exercises in scoping and prioritization because there&amp;#x27;s so damn many of these rabbit holes.</text></comment>