Comparing Ruby Performance
Posted by Scott Hughes Mon, 28 Nov 2005 19:50:00 GMT
My old friend P.O. Boykin recently took a look at Ruby (and other scripting languages) and came up with a very interesting post: Performance of Programming Languages
After spending time with so called “scripting languages” (a term that I feel is not a terribly well defined or useful), I have found that I enjoy programming in languages like Ruby, Python, and Boo more than languages like C, C++, Java, or C# (though C# is getting better and better as they improve the language). My question is: how much performance do I loose by adopting one these laguages. To answer this question I took a look at the Language Shootout site.
I hadn’t heard of the Language Shootout site; that’s a very interesting link. They compare the implementations of your favorite programming languages (and are very careful not to say they compare the actual language, just the implementation) and produce a whole lot of “at-a-glance” graphs.
I’m a very recent fan(atic) of Ruby. I still don’t “think” in Ruby, just because I don’t have enough trench time with it. But I subscribe to the Google group RSS feed for comp.lang.ruby, and it’s very common to find code snippets (usually in response to a question) that just make me smile. Since more than half of the work I do at my job is using a PC to communicate with a significantly slower device (parallel FPGA, usb or serial Micro, or a 1-Wire device), I try to sneak scripting solutions in wherever I can. If the PC takes 100x more cpu time to compute a message that is going to be put on a slow bus (several orders of magnitude slower than the cpu) noone is going to notice the loss of a few extra nanoseconds. That said, I usually need to hand code off to other people (those so-called “paying customers”) and using a more popular programming language (C or Java) makes that hand-off much easier.
But for some of my tasks, Ruby’s elegance outweighs any of the performance penalties. Ruby is still fairly young, so I’m hoping that in the near future it will reach a good level of general acceptance and gain some significant performance improvements (thanks to all the eyes it now has on it). Also, I think it’d be interesting to run the same benchmarks the Language Shootout guys did, but using either YARV [1] or RB2C [2]. Seems that if those projects don’t do better than vanilla Python, they should re-think their solution. It’d be nice to see if they are able to tighten the large margins between the Java or .NET runtime.
[1] YARV: Yet Another Ruby VM - http://www.atdot.net/yarv/
[2] RB2C : a Ruby to C converter http://www-lab09.kuee.kyoto-u.ac.jp/~hiwada/ruby/rb2c/


Articles Only

Thanks for the YARV link. It looks like there is some hope that YARV will improve performance. If I understand correctly, it may become the default VM for Ruby with Ruby 2.0.
RB2C however, looks moribund. The page hasn’t changed since early 2000.
I have also found these up-and-comers:
I am hoping one or both of the above projects really gets off the ground. Ruby on Mono would give me access to any .Net library from Ruby, and Parrot is supposed to allow Perl/Python/Ruby to all share code. Using CPAN from Ruby would be great.
“that’s a very interesting link” It’s always nice to be appreciated ;-)
The Computer Language Shootout is only as good as the programs people contribute - and we’re missing many Ruby programs.
The FAQ provides painfully detailed instructions “How can I contribute a program or a fixed-program?” http://shootout.alioth.debian.org/gp4/faq.php#contribute
“Also, I think it’d be interesting to run the same benchmarks the Language Shootout guys did, but using either YARV [1] or RB2C [2].”
See http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=yarv&lang2=ruby
There’s also libjit, or rather ‘ludicrous’ for Ruby, though…I’m not sure how complete it is it has a chance.