YARV Looking Promising, James's C is Not
I participated in the ICFP programming contest last weekend with a group of friends. We had a great time with the event and learned a ton. I thought I should share two interesting insights with others that might appreciate them.
First, YARV looks very promising for some general speed increases in Ruby. If you are not familiar with YARV, that's the virtual machine that will run Ruby 1.9. During the contest, we ran into some performance issues with our Ruby solution and after we had optimized all we could think of, we decided to try running our entry on the experimental YARV VM to see if it was faster there. Good news: it was a lot faster.
Please do not take these numbers as anything more than very non-scientific observations, but we did notice a huge speed increase on YARV. We were reliably waiting around 15 minutes for one section of our program to run on Ruby 1.8.4, but when we introduced YARV the same section generally ran in just under seven minutes. You heard me right there, it was over twice as fast. I think that's very promising news for the future of Ruby.
The not so good news is that it still just wasn't fast enough.
Of course we want to be able to use Ruby for as much as possible, but it is important to admit that it's just not fit for every job. The programming contest involved the creation of a small VM that ran many, many instructions from contest provided data files. In order to get that to a reasonable level of performance, you really needed some C.
The good news is that Ruby will easily allow you to drop down to C and integrate that code with your script. The bad news is that James's C is so rusty, that was a nightmare. Thank goodness one of my partners was more capable. He certainly carried us through.
I don't need C very often any more. I think it has literally been about a year since I last felt the need. However, there are jobs Ruby is a bit too slow to handle and when they come up, C is your best friend. I'm definitely brushing up on my C skills before next year's contest.