<story><title>Zero Cost Abstractions</title><url>https://ruudvanasseldonk.com/2016/11/30/zero-cost-abstractions</url></story><parent_chain></parent_chain><comment><author>mpweiher</author><text>&amp;gt;The only proper way to reason about the cost of these&lt;p&gt;&amp;gt;abstractions is to inspect the generated machine code.&lt;p&gt;To me, that&amp;#x27;s a big problem with a lot of these Heldencompilers.  They &lt;i&gt;may&lt;/i&gt; generate really optimal machine code.  Then again, they may not, and the difference between optimizations working well and not working well in runtime efficiency is so great (I&amp;#x27;ve measured 1000x for Swift) that they might as well be completely different languages.&lt;p&gt;For reference, 1000x means that 1 second turns into 16 minutes, and having that type of difference in something that&amp;#x27;s completely opaque is not a useful performance tool for me, because predictability is at least half the game in performance.  So something like Knuth&amp;#x27;s transformation systems that turn optimization into a dialogue between programmer, compiler and instrumentation seems like a better idea[1].&lt;p&gt;[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.cs.sjsu.edu&amp;#x2F;~mak&amp;#x2F;CS185C&amp;#x2F;KnuthStructuredProgrammingGoTo.pdf&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.cs.sjsu.edu&amp;#x2F;~mak&amp;#x2F;CS185C&amp;#x2F;KnuthStructuredProgrammi...&lt;/a&gt;</text></comment>
<story><title>Zero Cost Abstractions</title><url>https://ruudvanasseldonk.com/2016/11/30/zero-cost-abstractions</url></story><parent_chain></parent_chain><comment><author>etrain</author><text>This is pretty awesome. One key bit of information that the compiler has is that the coefficients are a constant array of length 12, which makes the loop unrolling possible and also means that the register magic is in play - it&amp;#x27;s seriously awesome that the compiler does this.&lt;p&gt;That said, I&amp;#x27;d expect something similar to happen with a well-written C program. Would equivalent abstractions in C++1{1,4,7} be &amp;quot;costly&amp;quot;?</text></comment>