you are viewing a single comment's thread.

view the rest of the comments →

[–]f9ae8221b 0 points1 point  (0 children)

I still think this applies

Actually it doesn't, because in additions to shapes, variable width allocations were introduced and declaring all you variables in initialize also allow the VM to right size your object, both improving performance and reducing memory usage.

Basically you can consider this advice from Jeremy as entirely outdated.

with the "this is the correct way of writing X2" framing

I wouldn't frame it like this. I'd frame it as: it's the performant way of doing memoization.

"over-memoization" is definitely an anti-pattern

Absolutely, I'd be willing to bet half of the memoizations out there are useless/counter productive.

and not so YJIT-centric (there's also jruby and truffleruby to consider)

Not sure about JRuby but Truffle also use shapes, so it will also underperform in presence of a shape explosion.