Live data from Hacker News

Fast Ruby – A collection of common Ruby idioms

github.com

1–10 of 27 posts

Re: Fast Ruby – A collection of common Ruby idioms

#4
post #2

Shouldn't some of those items be opened as a ticket to Ruby 2.x and standard library to ask them for a faster implementation?

Yes a lot of these can be solved - JRuby+Truffle for example removes the overhead of at least parallel assignment vs normal assignment, define_method vs def, send vs normal send, Proc#call vs yield.

Some of the others though, such as Array#bsearch vs Array#find, are just algorithmic complexity and not the fault of the implementation.

Re: Fast Ruby – A collection of common Ruby idioms

#8
I would advise against concluding anything with < 20% gain, the changes often impacts readability (the intention becomes less clear) and might as well be measurement errors or just be insignificant for any sort of real application. Not to mention, of course, these measurements are specific to a given system, implementation, etc.

Re: Fast Ruby – A collection of common Ruby idioms

#10
post #7

Really nice project, and there's a lot to learn from it. But I think if your choice is ruby then you are putting clean code above micro optimizations. And it often pays off.

Most examples aren't really about micro-optimizations. They're more about calling the appropriate method in the first place (count vs. size/length, gsub vs. sub/tr).
Post reply on HN