How I Made Ruby Faster Than Ruby

noteflakes.com

82 points by ciconia 3 days ago


swombat - 21 hours ago

Feels like a misleading headline. The author created another templating language alternative to ERB, found that it was slower than ERB, then optimise it until it was roundabout as fast as ERB given a relatively simple template.

The author then appears to draw the wrong conclusion:

> What I find most interesting about the changes I’ve made to code generation in P2, is that the currently compiled code is more than twice as fast as it was when P2 first came out, which just goes to show than in fact Ruby is not slow, it is actually quite fast, you just need to know how to write fast code! (And I guess this is true for any programming language.)

I love Ruby, but it is still a slow language on most benchmarks. That's ok. For most webapps, the bottleneck is not execution-time performance, it's the speed and joy of writing the code. Functionality that never got built because it was too annoying to build is infinitely slow. But there's no point in pretending Ruby, compared to, say, Rust, isn't a slow-as-molasses execution environment. It is. It's ok. It's optimised for developer happiness, not speed.

And yes, even so, you can write slow Ruby code and fast Ruby code. Again, which one makes sense is contextual. But it doesn't make the point that "Ruby isn't slow."

kayodelycaon - 10 hours ago

Neat. It automates the same kind of optimization I’ve done with ERB before (pre-compiled templates in constants). It means I don’t have to teach people were and how to optimize ERB.

To get faster this, you need to get out your profiling tools and your notebook.

Builder::XmlMarkup and strings are significantly more flexible and have many optimization points. (E.g. not escaping numbers.) They have the potential to be an order of magnitude faster. But you’ll be using that notebook to diagram where everything goes.

Sincere6066 - 18 hours ago

yo dawg meme? I think that meme's old enough to drink now