From: David Balmain Date: 2006-06-03T11:13:51+09:00 Subject: Re: Speed of Ruby program != Speed of Ruby language (was Re: Zed and Luis drop the bomb on Ruby's poor performance) On 6/3/06, Ryan Williams wrote: > I think Dave's point is that it's irrelevant what Ruby itself is > implemented in. The problem is that whenever performance dicussions > come up, instead of discussing how to imrpove the speed of > Ruby-the-language, people instead talk about how easy it is to use > languages other than Ruby for programs that are supposed to be fast. > > Dave wants to talk about how to make fast programs that are completely > written in Ruby. And I do too, though I have little to contribute > except to perhaps bring the discussion back in line. Maybe we could > talk about improving the speed of the Ruby implementation, or about > improving our use of the language. But can we have a discussion where > we pretend for a moment that we don't all want to run out and > implement things in C? > > -RYaN It's difficult to talk about the implementation of Ruby without talking about C because the (most common) implementation is in C. The work Koichi san is doing on YARV is great and I'm really looking forward to Ruby 2.0 but the answer to many performance problems in Ruby is still going to be to write C extensions. I'll give the work I'm doing on Ferret (port of Apache Lucene search library) as an example. Search can be a performance critical portion of many applications. Now the pure Ruby version of Ferret is about 100 times slower than the version with the C extension. Now along comes YARV. From what I've been hearing there is a 2-4 times speed up for some applications. That still leaves an order of magnitude difference. Now I'm not saying that writing C extensions is the answer to all your Ruby performance woes. Most of the time, a better algorithm will do the job. A faster implementation will help too. I will say however that Ruby and C together make a powerful combination and I think C is well worth learning. Not only will you be able to write C extensions when you need to, but you'll have a better understanding of the Ruby internals which will in turn help you write faster Ruby code. And it's really not that difficult a language to learn. C is not a dirty word, Dave