I know that’s a major reason why I don’t use them more often. I was bitten by reject vs reject! In one of my more notable “oh shit. I just broke everything” events.https://twitter.com/nateberkopec/status/1038125248045047809 …
-
-
-
Replying to @nateberkopec @derekprior
Is there a reason to prefer the destructive/! version other than performance (because Ruby)? My default is to use non-destructive methods and treat collections immutable/append-only. Defer optimization.
2 replies 0 retweets 0 likes -
Replying to @doctorzaius @nateberkopec
Agree. I've had very few cases in apps where the reduced allocations of the `!` methods mattered. However, I also see people intentionally use the ! methods for their different returns which makes the code hard for me to understand.
2 replies 0 retweets 2 likes -
Replying to @derekprior @doctorzaius
We really got a big speedup on the sentry-raven gem with `!` methods, because half of that gem's work is essentially putting very large hashes through a series of mutations. When you need !, you really really need it.
1 reply 0 retweets 1 like -
Gems are an entirely different animal though. They tend to have hotter hot paths than app code, and are more likely to live in the hot path than not. Plus as an author of a gem you have more of a responsibility to your users to pay attention to perf
1 reply 0 retweets 3 likes -
Replying to @sgrif @nateberkopec and
But that doesn't mean that changes which are significant in gems are something that app developers should care about or are likely to benefit from, unless it's somewhere that there's a known perf problem.
1 reply 0 retweets 2 likes -
Replying to @sgrif @nateberkopec and
Most pathological example -- I remember a few years ago way too many people were sharing an article "http://block.call is twice as slow as yield!!!!" telling app developers to stop using `&block` which was just...........
1 reply 0 retweets 0 likes
That case is VM specific, and also just not important. It's 8ns on my personal machine, which will not add up to a measurable difference in app or gem code. We have *one* place in Rails which cares https://github.com/rails/rails/blob/dd29fabebf1b702031213361b7757be5892cd59f/activerecord/lib/active_record/attribute_methods/read.rb#L67-L79 … and it's the hottest of hot paths
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.