← Back to context

Comment by pmarreck

18 hours ago

How fast is Ruby, lately?

I haven't used it in about 10 years

If you want to compare it against other languages you could look at The Computer Language Benchmarks Game [1], which is an ongoing comparison of various programs written in various popular languages. You should always take all these benchmarks with a pinch of salt though since they are never truly apples-to-apples. That said, Ruby seems to measure slightly faster than Python and Lua, slightly slower than PHP, and maybe 1 order of magnitude slower than Node.js, just to compare it with other similar languages.

Compared to itself from 10 years ago I think it's made great progress. Can't put a number to it but I wouldn't be surprised if it's 2x or 3x faster, especially with the "new" JIT (YJIT) enabled. The JIT comes with a memory usage penalty though. You can see some benchmarks over time (although not going back as far as 10 years) at https://speed.ruby-lang.org

1: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

I have a prototype ahead-of-time Ruby compiler. It's woefully incomplete - I've just recently picked it up again after years of inactivity, with heavy AI use to pursue rubyspec compliance (it's nowhere close). The point of mentioning that: MRI - the main Ruby interpreter - is fast enough that competing against it with an unoptimized compiler goes really badly unless you do a lot to optimise the garbage collector (I haven't yet).

So it's "fast". There's plenty more that can be done to make it much faster still, but even before yjit, MRI had gotten pretty decent.

It's gotten faster, but so have other languages. The broad strokes rankings haven't changed so much that raw performance would change your mind today compared to 2015.

> How fast is Ruby, lately?

I did recent testing that showed it to be faster than Python but slower than Lua: Lua, Ruby and Python ran my benchmark in 12, 18 and 25 seconds respectively.

This was measured using the latest versions of each language (5.4, 3.4 and 3.13), using only the interpreters, no JITs.

> I haven't used it in about 10 years

It looks like the relative performance of the three languages hasn't changed much since I did a similar benchmark with Ruby 2.0, about that long ago.