Ruby (was: Re: Perl, Python and noo perl SEC: UNCLASSIFIED)

Matthew Hawkins matthew at topic.com.au
Wed Apr 10 14:02:54 EST 2002


On Fri, 05 Apr 2002, Cox, Neil wrote:
> Anyone on the list have experience with Ruby?  I've just started looking at
> it and I'm intrigued.

I did some work in ruby the other day.  I didn't get to use too many of
the features, the task wasn't complicated enough to even start making
classes.  I installed ruby-dbi and did some more database crap with it.
I think it was a little bit easier than Python to do the same thing, but
only because it has DBI and Python doesn't.  The source code was shorter
and was also quicker to write (not because it was shorter, just becasue
in my mind it was easier to get it all straight).  The script I don't
think was any faster or slower than the equivalent Python one I also
wrote for comparison.  Mind you, a lot of the time was spent pissfarting
about waiting for MySQL to catch up ;-)  Come on, all I wanted was to
left join three huge tables with no indexes and grab 12 fields total (a
few from each) if a particular condition was true.  It wasn't rocket
science ;)

Ahem.  Anyway, while waiting for MySQL to get jiggy with it, I went
through some articles on IBM's DeveloperWorks and a few other ones
linked from http://www.ruby-lang.org/ and played around with the eval.rb
script and stuff.  I think its definately got a good feel to it, and I
very much like how it seems to have taken all the best things from existing
languages.
For example, like Java everything is an object.  So it's perfectly valid
to have an expression like:

len = "Some string I make up on the spot".length

which really freaks me out, since I don't usually attribute traditional
constant character arrays as having callable methods.
Another thing I like is that the scope of a variable is implicit from
it's name - var is local, $var is global, VAR is a constant, @var is an
instance variable.  That last one is nice because one thing that always
bugs me in Python is having to refer to instance variables as 'self.var'.
gzip would have a field day with the number of times you have to use
'self' in a decent sized Python program!

You can also override both class and instance methods of any class, at
runtime!  Perhaps this almost makes up for only having single
inheritance...

Blah blah blah blah.

-- 
Matt




More information about the linux mailing list