<story><title>What Is the Minimal Set of Optimizations Needed for Zero-Cost Abstraction?</title><url>https://robert.ocallahan.org/2020/08/what-is-minimal-set-of-optimizations.html</url></story><parent_chain></parent_chain><comment><author>modeless</author><text>The reason compilation time is a problem is that compiler architecture is stuck in the 1970s, at least for systems programming languages. Compilers make you wait while they repeat the same work over and over again, thousands of times. Trillions, if you count the work globally. How many times has &amp;lt;vector&amp;gt; been parsed over the years?&lt;p&gt;In a world where compiler architecture had actually advanced, you would download a precompiled binary alongside the source, identical to what you would have produced with a clean build, and that binary would be updated incrementally as you type code. If you made a change affecting a large part of the binary that couldn&amp;#x27;t be applied immediately, JIT techniques would be used to allow you to run and test the program anyway before it finished compiling.&lt;p&gt;There is no fundamental reason why anyone should &lt;i&gt;ever&lt;/i&gt; have to wait for a compiler. And if you didn&amp;#x27;t have to wait, then it would free the compiler to spend potentially &lt;i&gt;much&lt;/i&gt; more time doing optimizations, actually improving the final binary.&lt;p&gt;The zapcc project shows a bit of the potential for improvement in build times, though it&amp;#x27;s just scratching the surface. &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;yrnkrn&amp;#x2F;zapcc&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;yrnkrn&amp;#x2F;zapcc&lt;/a&gt;</text></comment>
<story><title>What Is the Minimal Set of Optimizations Needed for Zero-Cost Abstraction?</title><url>https://robert.ocallahan.org/2020/08/what-is-minimal-set-of-optimizations.html</url></story><parent_chain></parent_chain><comment><author>fanf2</author><text>My list would be:&lt;p&gt;- Inlining&lt;p&gt;- Common subexpression elimination&lt;p&gt;- Dead code elimination&lt;p&gt;- Monomorphization&lt;p&gt;I get the impression that 2 and 3 come out of an SSA middle end fairly straightforwardly, along with the article’s copy propagation and dead store elimination.&lt;p&gt;The biggie is monomorphization, which is part of the language in C++. The alternative is uniform representation of generic values, 
which implies boxing and indirection instead. I understand Rust does not hide representations enough for the compiler to be able to choose whether or not to monomorphize. Interestingly, the Go generics discussion seems to be heading towards a design where the compiler does have this option.</text></comment>