Ruby

I use scripting languages a lot in my daily work. I started programming profesionally on DOS/Windows and the command shell wasn't very impressive. Some people used bath file enhancers, I mostly used AWK. Sometimes I cheated and telnet'ed into a UNIX box and did some of the work there. Sometime in 1997 I discovered Perl. If you're working on Windows, you'll want ActivePerl. On UNIX, there's a fair chance that your system already comes with Perl by default. Just try "perl -v" from the shell.

I stayed with Perl for several years and haven't found a compelling reason to switch (Python came close though ;->) until I read about Ruby. Beginning of 2000 I bought a book called The Pragmatic Programmer. The authors recommended learning at least one new language per year. After reading the book I visited their web site and found out that they had chosen Ruby as their "next" language. I decided to take a look at it.

Why Ruby?

The official explanation says:
Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable.

To me Ruby feels like a scripting version of Smalltalk, but with Perl's libraries and regular expression support and using Eiffel/Ada syntax.

Even so I'm not doing Ruby any justice as it also features closures, exception handling and very good support for writing C extensions.

Here's a simple example of Ruby code:

# extend the built-in Integer class by adding the factorial
# function to it.
class Integer
  def factorial
    return 1 if self == 0
    f = 1
    n = self
    while n>0
      f *= n
      n -= 1
    end
    return f
  end
end

# if you do "ruby -w fact.rb 200" the script will print out
# the factorial of 200. 
puts ARGV[0].to_i.factorial

Learn more about Ruby

The Official Ruby Site
The Pragmatic Duo on Ruby (Dr. Dobbs Journal)

The Pragmmatic Programmers have been central in trying to make Ruby a mainstream language. They have set up a very nice Ruby site and a Wiki. They have also written the first Ruby book which you can read online, although I recommend you to buy the print version anyway.

Andy and Dave's Ruby Links