<story><title>The Dynamic Def – abusing Ruby&apos;s def statement</title><url>http://weblog.jamisbuck.org/2015/10/17/dynamic-def.html</url></story><parent_chain></parent_chain><comment><author>bascule</author><text>Defining instance-specific behavior of any kind is catastrophic to method caching. JRuby has a hierarchical method cache so it can clear only what&amp;#x27;s needed, but MRI does not:&lt;p&gt;&lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;jamesgolick.com&amp;#x2F;2013&amp;#x2F;4&amp;#x2F;14&amp;#x2F;mris-method-caches.html&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;jamesgolick.com&amp;#x2F;2013&amp;#x2F;4&amp;#x2F;14&amp;#x2F;mris-method-caches.html&lt;/a&gt;&lt;p&gt;The late, great James Golick had a patch to add one once, but it never got merged upstream.&lt;p&gt;If you care about performance even the tiniest bit at all whatsoever, please don&amp;#x27;t use the techniques discussed in the OP in production code or in your gems. It may make your memos 30% faster on a microbenchmark... while causing the rest of your program to run considerably slower.</text></comment>
<story><title>The Dynamic Def – abusing Ruby&apos;s def statement</title><url>http://weblog.jamisbuck.org/2015/10/17/dynamic-def.html</url></story><parent_chain></parent_chain><comment><author>wdewind</author><text>Cool article about the craziness of Ruby.  Ruby is a frustrating language.  The oauth gem, for instance, redefines &amp;#x27;==(val)&amp;#x27; on the AccessToken to &amp;#x27;Base64.encode(self.signature) == Base64.encode(val).&amp;#x27;&lt;p&gt;This stuff feels really dangerous and unnecessary.  I spend a lot of time on code reviews pointing out bad features of Ruby (and Rails) that we shouldn&amp;#x27;t be using because they break application flow and make it significantly harder to reason about the code for the small benefit of decreasing a few lines.  But it&amp;#x27;s certainly fun to talk about :)</text></comment>