<story><title>What can we learn from how compilers are designed?</title><url>http://www.tedinski.com/2018/03/13/how-compilers-are-designed.html</url></story><parent_chain><item><author>justinpombrio</author><text>&amp;gt; One of the interesting insights I got while building my own compiler was that despite what every compiler book says, there are languages that can be compiled on the fly without building an AST.&lt;p&gt;PL (but not compiler) researcher here. What you&amp;#x27;re saying sounds to me like &amp;quot;One of the interesting insights I got while programming my own game was that despite what every game programming book says, there are games that can be programmed without defining any functions.&amp;quot; I mean, yes, you &lt;i&gt;can&lt;/i&gt; do that, and it may in fact be more efficient, but it&amp;#x27;s going to cause trouble down the line if you ever want to do something more complex.</text></item><item><author>mojuba</author><text>&amp;gt; My view is that learning and writing a simple compiler will make most of developers on notch better.&lt;p&gt;Agreed. One of the interesting insights I got while building my own compiler was that despite what every compiler book says, there are languages that can be compiled on the fly without building an AST. I&amp;#x27;d say for most languages it&amp;#x27;s an unnecessary step that makes compilation slower and more resource hungry. However, compiling without AST is a next-level skill, another notch I think.</text></item><item><author>vicpara</author><text>It&amp;#x27;s a good article. Indeed, compiling a programming language is such a complex job that is frankly quickly dismissed and taken for granted. My view is that learning and writing a simple compiler will make most of developers on notch better. The very least you&amp;#x27;ll understand why parsing HTML or XML with regex is such a bad idea :)&lt;p&gt;Another golden resource is the Dragon book: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Compilers:_Principles,_Techniques,_and_Tools&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Compilers:_Principles,_Techniq...&lt;/a&gt;</text></item></parent_chain><comment><author>munificent</author><text>&lt;i&gt;&amp;gt; What you&amp;#x27;re saying sounds to me like &amp;quot;One of the interesting insights I got while programming my own game was that despite what every game programming book says, there are games that can be programmed without defining any functions.&amp;quot;&lt;/i&gt;&lt;p&gt;Ex-game programmer and current PL programmer here. I think a better analogy is that you can make a game without having a scene graph. And, indeed, you can. And it works fine for many simple games, though as some scales it starts to be a hindrance.</text></comment>
<story><title>What can we learn from how compilers are designed?</title><url>http://www.tedinski.com/2018/03/13/how-compilers-are-designed.html</url></story><parent_chain><item><author>justinpombrio</author><text>&amp;gt; One of the interesting insights I got while building my own compiler was that despite what every compiler book says, there are languages that can be compiled on the fly without building an AST.&lt;p&gt;PL (but not compiler) researcher here. What you&amp;#x27;re saying sounds to me like &amp;quot;One of the interesting insights I got while programming my own game was that despite what every game programming book says, there are games that can be programmed without defining any functions.&amp;quot; I mean, yes, you &lt;i&gt;can&lt;/i&gt; do that, and it may in fact be more efficient, but it&amp;#x27;s going to cause trouble down the line if you ever want to do something more complex.</text></item><item><author>mojuba</author><text>&amp;gt; My view is that learning and writing a simple compiler will make most of developers on notch better.&lt;p&gt;Agreed. One of the interesting insights I got while building my own compiler was that despite what every compiler book says, there are languages that can be compiled on the fly without building an AST. I&amp;#x27;d say for most languages it&amp;#x27;s an unnecessary step that makes compilation slower and more resource hungry. However, compiling without AST is a next-level skill, another notch I think.</text></item><item><author>vicpara</author><text>It&amp;#x27;s a good article. Indeed, compiling a programming language is such a complex job that is frankly quickly dismissed and taken for granted. My view is that learning and writing a simple compiler will make most of developers on notch better. The very least you&amp;#x27;ll understand why parsing HTML or XML with regex is such a bad idea :)&lt;p&gt;Another golden resource is the Dragon book: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Compilers:_Principles,_Techniques,_and_Tools&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Compilers:_Principles,_Techniq...&lt;/a&gt;</text></item></parent_chain><comment><author>compiler-guy</author><text>Yeah, the grandparent is only true if you don&amp;#x27;t want to do interesting things with the language, like nearly any but the most basic peephole optimization.&lt;p&gt;But a fun fact, if you know about single-pass compiling, you can figure out a lot of why the original C syntax is what it is. A declaration is a &amp;quot;reserve some memory&amp;quot; statement. Local variables had to be declared at the beginning of scope so that the compiler could deallocate them at scope close. Without an AST, the compiler had to produce instructions immediately.&lt;p&gt;With a true AST, you don&amp;#x27;t need such a restrictive syntax.&lt;p&gt;There are many other possible examples.</text></comment>