Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Performance

I'm pretty keen to develop my first Ruby app, as my company has finally blessed its use internally.

In everything I've read about Ruby up to v1.8, there is never anything positive said about performance, but I've found nothing about version 1.9. The last figures I saw about 1.8 had it drastically slower than just about everything out there, so I'm hoping this was addressed in 1.9.

Has performance drastically improved? Are there some concrete things that can be done with Ruby apps (or things to avoid) to keep performance at the best possible level?

like image 327
Steve M Avatar asked Aug 25 '08 12:08

Steve M


People also ask

Is Ruby still relevant in 2022?

Although way behind main contenders, such as PHP or Python, Ruby still makes the cut for the 20 most popular programming languages list in 2022. The 2022 edition of Stack Overflow Annual Developer Survey also places RoR in a similar spot.

Which is faster Ruby or Python?

There is a perception that Python is faster than Ruby, and this has often led teams to prefer it over Ruby for web development. The Ruby community is painfully aware of this, and Ruby has gotten way faster over the years. Now, in benchmarks, Ruby performs just about as well as Python, if not better.

Why is Ruby slow?

Ruby is an interpreted language and interpreted languages will tend to be slower than compiled ones. Ruby uses garbage collection (though C#, which also uses garbage collection, comes out two orders of magnitude ahead of Ruby, Python, PHP etc. in the more algorithmic, less memory-allocation-intensive benchmarks above)

Is Ruby a performant?

Being an interpreted language, Ruby is not as performant as C/C++, Rust, and Go. Although not impossible, it is hard to scale a Ruby on Rails application. Moreover, the lack of static types in Ruby makes it hard to refactor code as the development team grows.


2 Answers

There are some benchmarks of 1.8 vs 1.9 at http://www.rubychan.de/share/yarv_speedups.html. Overall, it looks like 1.9 is a lot faster in most cases.

like image 175
Matt Sheppard Avatar answered Sep 22 '22 06:09

Matt Sheppard


If scalability and performance are really important to you you can also check out Ruby Enterprise Edition. It's a custom implementation of the Ruby interpreter that's supposed to be much better about memory allocation and garbage collection. I haven't seen any objective metrics comparing it directly to JRuby, but all of the anectdotal evidence I've heard has been very very good.

This is from the same company that created Passenger (aka mod_rails) which you should definitely check out as a rails deployment solution if you decide not to go the JRuby route.

like image 39
Mike Deck Avatar answered Sep 21 '22 06:09

Mike Deck