<story><title>JIT-optimized Ruby can outperform a C extension</title><url>https://railsatscale.com/2023-08-29-ruby-outperforms-c/</url></story><parent_chain></parent_chain><comment><author>rolae</author><text>People say the title of the article &amp;quot;Ruby Outperforms C: Breaking the Catch-22&amp;quot; is misleading, which is true, this is about Ruby code optimized by JIT outperforming a extension written in C.&lt;p&gt;But to give some context: the author Aaron Patterson is a Ruby and a Rails core team member. The article and headline is clearly targeting the ruby community, where this article has been very well received. I think it&amp;#x27;s a good title for the intended audience.&lt;p&gt;The post clarifies in the first section:&lt;p&gt;&amp;gt; In this post I’d like to present one data point in favor of maintaining a pure Ruby codebase, and then discuss some challenges and downsides of writing native extensions. Finally we’ll look at YJIT optimizations and why they don’t work as well with native code in the mix.&lt;p&gt;edit: added original title of the hackernews post &amp;#x2F; article</text></comment>
<story><title>JIT-optimized Ruby can outperform a C extension</title><url>https://railsatscale.com/2023-08-29-ruby-outperforms-c/</url></story><parent_chain></parent_chain><comment><author>chucke</author><text>This article outlines well the paradox that JITs require to be truly more efficient: if more of the target language is available to optimize, it&amp;#x27;ll get waaay more optimized, compared to dropping down to the layer below and try to hand-stitch it.&lt;p&gt;Of course, there is massive overhead in doing so. Just look at go, which had to rewrite practically everything already available in go, and must always require a native implementation (protobuf for example shares the underlying interface across ruby, python, php... but then has a full separate implementation in go, and java I think). And they have the budget for it at least, Google won&amp;#x27;t let go die under the overhead it created for itself.&lt;p&gt;So definitely, write more ruby, enough of those &amp;quot;fast-C gem - rewritten as C extension&amp;quot;, but still keep using low level libraries like libpq.</text></comment>