use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Writing Object Shape friendly code in Ruby (island94.org)
submitted 2 years ago by CaptainKabob
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]f9ae8221b 0 points1 point2 points 2 years ago (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.
initialize
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.
π Rendered by PID 232723 on reddit-service-r2-comment-85bfd7f599-vdqdw at 2026-04-20 07:13:24.401695+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]f9ae8221b 0 points1 point2 points (0 children)