2007: Ruby

June 6, 2007

While Meredith was writing her level 2 CFA exam this past weekend, I had the chance to dig into the first 100 pages of Programming Ruby. I figure it makes sense to try and do a good job learning Ruby first before learning Ruby on Rails.

Admitedly, I'm very split minded about Ruby right now, sort of like I am about Perl: There are a lot of things that I really like, but there are also some things that make me cringe. Here are some things that I like/dislike so far.

The good:

Ruby is very object oriented, which makes for a clean namespace. One of my complaints about PHP (and Perl) is that they are function-oriented, and so you get these somewhat long, hard to remember function names. For example, PHP has: file_get_contents, simplexml_load_file, strtotime, etc.

Ruby is very good at reducing how much the developer has to type. This is one of my gripes about Java, but also C++ to a certain extent: In many places they are wordy and bloated. For instance, in C++:

Words Words;
Words::iterator Iter;

for ( Iter = Words.begin() ;
      Iter != Words.end() ;
      Iter++ )
{
    cout << *Iter;
}

In Ruby:

words.each {|word| puts word}

The bad:

Major complaint: Everything that I've read has indicated that Ruby is slow. Not just slow, dog slow :(

Ruby's code block construct is fascinating, but it feels a bit unnatural. It will take some time before I have a better feeling for whether I like or dislike code blocks.

Related point: Ruby accomplishes a lot by levereging its object oriented namespace and being clever with the code block construct. But this results in a bit of an unnatural style that doesn't mimick natural language that well. For instance:

words.each {|word| puts word}

... is not as natural in form as Perl's...

for each $word (@words)
{
    print "$word\n";
}

April 12, 2007

Last week I picked up Programming Ruby at Chapters, and this week I lucked out by getting Agile Web Development with Rails for free from Scott at work since he had an updated version of the book. I can't wait wait to dive in -- hopefully this language lives up to all of the hype. I'm optimistic.