How I Stopped Worrying and Learned to Love Ruby

The past week was very enlightening. Reading the PickAxe books, I felt like I was going back to my Perl-learning days, with all their headaches and all their joy. I can’t believe I haven’t learned Ruby before.

In Ruby, where everything’s an Object, life is very simple: Everything descends from an Object class, and you can easily manipulate each and every object’s properties during runtime (that’s where Rails gets its magic from). This approach gives Ruby flexibility similar to Perl.

I keep bringing Perl up because it’s the first language that I learned, the first language that I “mastered”, and the language I enjoying coding in the most. The problem is my poor brain is built to compare and contrast, so I can’t help but get myself into a Perl vs. Ruby argument, especially that I’ve already done my Perl vs. PHP homework.

I admit I was turned off a little by the hype that is Rails. Granted, Rails is amazing, and 37signals’ marketing brilliantly associated Rails with Ruby. But if Rails turns out to be a fad, or it gets smeared by FUD campaigns, Ruby will be affected just the same.

However, putting popularity contests aside, Ruby’s zen-like sensation left me wondering whether I should use it for any serious projects.

My first (and most important) gripe was that Ruby’s performance suffers at least double as much as the next scripting language. The language shootout page clearly shows that Ruby sucks in most benchmarks. I’m not even going to mention Ruby vs. C or vs. Java because the score difference is so huge that Ruby doesn’t stand a chance. It could be because nobody paid attention to Ruby’s implementation, or because Matz wanted to keep the source code clean, or because Ruby doesn’t use a VM (like Python) and doesn’t have a 20-year-old hacker community (like Perl).

After much thought, I could only come to a single conclusion: It doesn’t matter! And the reason it doesn’t is because Ruby suffers not by design, but by implementation. But then again, every single language I know went through that path: Java was slow until 1.4, Python was slow until 2.3 (or so I believe), Perl was slow until 5.6, PHP was slow until 4.x, but they eventually solved those problems; after all, the rule is: Make it work, then make it fast. But In all honesty, if my problems can be solved by buying a few more server boxes, then the hell with it, I’ll use Ruby.

Second gripe was the availability of libraries. Ruby’s Gems are no where near CPAN nor JDK. There exists some very interesting stuff, but the vast majority of libraries pale in comparison to what’s available with more mature languages. Funny thing is, it doesn’t matter either. Nothing in software engineering says you can’t use other people’s work, in fact that’s why things like pipes exist: to bridge different tools together. Plus, Ruby’s mkmf utilities make it a lot easier to bind C libraries to Ruby. Now guess what, Perl, Python and PHP are all “libraries”, in a sense that the executable itself is just a wrapper around the shared object that is the language interpreter. This means we can implement Inline::Perl and Inline::Python, just like Perl’s Inline::Ruby and Inline::C.

The last gripe was Web server support. It’s not enough that Ruby is slow, its server support at the moment seems more like an experiment than a serious project. mod_ruby cracks under pressure, and it’s not nearly as flexible as mod_perl. Now now, there’s nothing to worry about, Ruby’s FastCGI performance can hold your business logic together. It’s still not the fastest, but FastCGI eliminates start up cost, and that is one expensive operation.

And that was only the surface of my internal monologue. It’s relatively easy to learn a new language, but it’s damn hard to forget about your emotional attachment to another. Programmers know this, and that’s part of why the Java community went crazy when Rails (and inherently Ruby) got all the attention.

So here’s my advice: Learn Ruby anyway, because it’s worth having a mini epiphany. But most importantly, learn to program, because at the end of the day, it’s not the language that matters, it’s those who know how to use it.

Comments (2)

  1. dotone wrote:

    I was so close to ditch my beloved PHP for RoR, at the end of the day it’s all RAD that matters. But went back to polishing my PHP skills better, and got myself down with PHPCake, it rocks.

    Neat summary I didn’t get the chance to even think in all those terms about it, me likes this post.

    Wednesday, May 2, 2007 at 1:00am #
  2. I took a look at Cake, and it follows a very similar philosophy to Rails. But Rails’ power comes from the language itself not only good design.

    I’m still having mixed feelings about Rails, it has its limitations just like any other framework.

    Wednesday, May 2, 2007 at 1:36am #