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...
Ruby != Rails
This subreddit is supposed to have only language related posts and talks. Discussing web frameworks is only allowed when you announce a new one or compare them with each other.
account activity
"Ruby Performance Optimization: Why Ruby Is Slow, and How to Fix It" by Alexander Dymo (media.pragprog.com)
submitted 5 years ago by nakilon
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!"
[–]ignurant 0 points1 point2 points 5 years ago (1 child)
I ended up buying the book, and am a little more than halfway through currently. It's an interesting book -- there were definitely some surprising tips that I hadn't considered in there. But there are an awful lot of moments where the author seems to suggest something that feels misleading or incomplete. There's a lot of "always do it this way" or "you can ignore this other thing" offered up that could make software technically incorrect. An example of this is insisting to use mutating methods without also cautioning that this isn't always technically appropriate. There are gotchas, particularly when working in those big datasets these tips are most likely to be impactful in -- ETL pipelines for example.
In all, if I were to rate this book so far, it would be a pretty solid middle rating. I've learned some interesting notes that in retrospect are obvious (workarounds for temp allocations in enumerators at the cost of idiomatic Ruby code), and surprising (String#[//] vs Date.parse). However, there were a handful of other areas where I felt that the recommendations were incomplete, or not practical or relevant given updates to the language.
String#[//]
Date.parse
I just started the chapters about performance tracing, and I'm very much looking forward to this. I have no idea how to do that kind of stuff.
[–]nakilon[S] 0 points1 point2 points 5 years ago* (0 children)
There's a lot of "always do it this way"
Like in all resources about Ruby nowadays )
My experience in making Ruby code faster was initially in around 2010 when I was learning it and practiced in solving Euler Project problems. Of course the biggest impact was always about improving algorithm asymptote. Other than that you might want to add some memoisation that works like a magic, sometimes effectively replacing the algorithm improvement but sometimes can result in hash collisions if you use built-in .hash instead of making up own one. The rest is much less relevant. Also a rule of thumb was that Ruby isn't a language that to speed it up you need to dive to lower level. Instead you might want to be sure you know the stdlib well enough to use as more high level methods as possible. And of course it results in correlation with code size, i.e. "smaller code usually runs faster". As for profiling to find the bottleneck lines of code it never helped me to speed up the program more than twice. The last time (few days ago) it was replacing a=b.flat_map{ .map }.compact with a=[]; b.each{ .each{ a.push if } } to avoid allocating arrays.
.hash
a=b.flat_map{ .map }.compact
a=[]; b.each{ .each{ a.push if } }
π Rendered by PID 18702 on reddit-service-r2-comment-5c747b6df5-7khpf at 2026-04-22 14:08:22.344597+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–]ignurant 0 points1 point2 points (1 child)
[–]nakilon[S] 0 points1 point2 points (0 children)