Remix.run Logo
faangguyindia 3 hours ago

People think Ruby is a slow language, but little do they know Ruby is a slower language than Go. But ruby these days is faster than Python.

Crestwave an hour ago | parent | next [-]

> little do they know Ruby is a slower language than Go

Isn't it generally expected for a feature-packed interpreted language to be slower than a minimal compiled language?

Alifatisk an hour ago | parent | prev | next [-]

But who cares really? I am not using Ruby for HPC. I use it for prototyping, oneliners for ETL and to glue different moving parts in a system or network together. That's it. Its not doing the heavy lifting anyways.

dahrkael 3 hours ago | parent | prev | next [-]

when ruby was trendy the 1.9 branch was still cooking so in a lot of people's mind it is veery slow

rco8786 an hour ago | parent [-]

Yea. Modern Ruby is "fast enough", but it's very real that when Ruby was hitting its peak it was dog slow. It's hard to shake those sorts of reputations (similar to the "can't scale" reputation that Rails got because of Twitter)

shevy-java 2 hours ago | parent | prev [-]

The speed argument never convinced me in general, in that whether it is perl, ruby or python, they are all slower than C. So the comparisons really are odd to me.

The "scripting" languages should of course not try to be slow, but people rarely use them for speed-reasons; they use these languages for gains in productivity and ease of writing code, adding features and so forth. That should be the primary focus point.

In the future we may no longer have such a speed penalty anyway.

johnfink8 7 minutes ago | parent | next [-]

slow is relative and frequently irrelevant. If you're just always waiting for network, or for results from postgres or redis or something, then a 100x speedup in your code won't change the user experience. And if you're doing computationally hard work in ruby or especially python, you're doing it wrong because either someone already wrote a native library to do it or you should.

librasteve an hour ago | parent | prev | next [-]

I would “up” this a little and say that scripting languages “should” be slow in comparison to low level compiled languages. We want eg. runtime evaluation of multis dependent on type. For (cod) example:

  subset Even of Int where *  %% 2;
  subset Odd  of Int where * !%% 2;

  multi foo(Even $i) { ‘fizz’ }
  multi foo(Odd  $i) { ‘buzz’ }

  say foo for ^9;
WJW an hour ago | parent | prev [-]

There's also "slow compared to C" and "slow enough that you notice when using it as an interactive shell". Running something like `Dir.each_child('.') {|x| p x}` in the interpreter completes in 1.3 milliseconds, which includes all the separate print calls. It could be much faster if we compute the string to print first and then only issue a single print call, but this is deliberately inefficient to show it doesn't matter in this usecase.

I wouldn't use Ruby for high performance computing. But for scripting (where runtime is not critical), web services (where transport latency will usually far outstrip the few milliseconds your handler takes) or shell use (where humans aren't fast enough to issue a new command every millisecond anyway), Ruby is more than fast enough.