Ruby: Productive Programming Language

A brief overview of popular languages and how Ruby matches up.

Every few years something significant happens in the land of computer programming. In my opinion the Ruby computer language is such a landmark.

Over the years I have seen programmer productivity go up. These are no hard measured calculations, but I have the impression that every five years the speed of delivering software doubles. Not only that, the curve for writing maintainable software appears to increase linearly too. A lot of that speed can be attributed to the tools of a developer, and core to these tools is the computer language.

A Short Overview of Mainstream Languages

Computer languages are essentially alike. There are more similarities than differences between any language. Nevertheless, the differences have a large impact on solving problems, finding ways of expression and human interaction. For example, LISP, a language of great beauty and simplicity in conception, reflects its allegiance more to computers than to humans. A language easy to interpret is not necessarily easy to program, as many a student can attest. LISP's most amazing feature is that it shows with how few rules one can create a powerful computer language.

Structured languages like Pascal and C clearly bridged a gap between native assembler and quick, human-readable coding. C is still widely used where performance matters--it is possible to write close to the assembler, as the Linux and BSD kernels prove.

With C++ in the early nineties, I personally went through a period of exploration and discovery. Classes, objects, containers, operator overloading, the works. Reading Stroustrup's classic book was crucial to understanding C++ as a language, and I loved it. But with hindsight I can see it takes something extra to become productive in C++; it is not for everyone.

Java came to the rescue. A much simpler language with an elegance in OOP (object-oriented programming), Java does have some down sides, like slow JVMs dealing with large libraries. The language itself has some short comings too. Many experienced C++ programmers use Java, and the complaint will come that it feels like working with their hands tied behind the back. Nevertheless Java is great for corporate-type team programming efforts. As a language it goes some way in enforcing structure and using OOP concepts.

In parallel, two other languages made a mark in the nineties: Perl and Python. Both are (interpreted) scripting languages and have some real advantages over C++ and Java in terms of delivery time of software (more on that below). With current levels of computing power, performance is hardly an issue for most "user-land" software.

Perl was a revolution in a way. and most of its productivity boost was due to the introduction of a full programming language with light notation for regular expressions, arrays and especially hashes.

Perl has some real problems, though, as almost everyone will assert who has participated in large Perl programming efforts. Perl has OOP extensions, but they are non-obvious and laborious. I did enjoy learning Perl OOP because it taught me a lot about OOP itself and how to implement OOP in a language as a single hack. Writing Perl OOP, however, is no joy. Maintaining a large Perl source base is only possible with the highest level of discipline by the coders, and the language itself does not help enforcing correct coding practices.

Python is cleaner as a language though its OOP was added as an afterthought--and it shows. I spent some serious time looking into Python and did not like it that much. It gives a lot but runs short, for example, with object elements all being public. In a team effort, that means developers have trouble understanding how their classes are being used (or abused). In this situation, I would even have trouble trusting my own code. Operator overloading is ugly, the syntax of a colon after an if statement I find to be non-obvious, etc. The indentation idea is clever, but somehow it doesn't improve code readability. In short, Python almost makes it but not quite.

Introducing Ruby

Late last year I got my hands on the Ruby book by the (self-named) pragmatic programmers, Dave Thomas and Andy Hunt. The book also has an on-line version. I read the book in one go, and it goes into the hall of fame of important computer books, as far as I am concerned, right next to the Stroustrup. After reading it, I almost skipped sleep for a week because I was so excited by the implications of Ruby, a programming language that reads like poetry.

The author of Ruby, Yukihiro Matsumoto, aka Matz, knows his languages (LISP, Small Talk, Perl, Python and others) and aimed to create his perfect language. Ruby follows the Principle of Least Surprise and, funny enough, gets close. It feels, in fact, exactly like the computer language I have wanted to design all my life (without really knowing it).

Ruby was developed after 1994 and does not carry the baggage of Perl and Python; it is the new kid on the block. It comes with extensive libraries, not as rich as Perl's CPAN, but after a year of working with Ruby, I haven't missed any critical components. Ruby is complete with HTML and FTP classes, CGI support, XML parsers, database libraries, GTK and Qt bindings and even a pure Ruby BTree library. It is also quite straightforward to link up Ruby and Python libraries, which gives it an even richer base. Ruby is well supported on UNIX and Windows; developing on UNIX and deploying on Windows works without a hitch, including GUI development.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Ruby: Productive Programming Language

Anonymous's picture

if you don't like such things like $! don't use it.
use $ERROR_INFO instead.
it's part of English library, more info at

Re: Ruby: Productive Programming Language

Anonymous's picture

"Your examples don't show any of this. Is the heavy

punctuation and inline regex something that is specific

to perl converts, or is it intrinsic to the language? "

In regards to "strange operator symbols" I suspect you're referring to what are known as 'sigils' in the Perl world.

In Perl sigils are used heavily because they denote the type of the object they refer to. In Ruby they're used much less because they refer to scope not type.

So In Ruby:

$ - global scope (shouldn't be used much of course ;-)

@- instance scope

@@ - class scope

I actually find them pretty handy so that you can tell the scope of a variable 'at-a-glance'.

As far as the global variables go (things like $!, $% , etc. ) Ruby has inherited a lot of them from Perl and personally I don't like them (though I really like Ruby a lot!). Fortuneately you can use the English module which gives them readable names.

I, like the author of this article, also came from a Perl background (six years) but I've also dabbled with Java and I've done a bit of C/C++ programming. I've been using Ruby for over a year now and I hope to not have to use Perl again (Please, don't make me use Perl! NO! Arrgghhh!! No Perl please!!!! I can't stand to look at Perl anymore and I really used to like it before I ran into Ruby). Someone said that

Ruby is Perl's younger, prettier sister.

Not sure what you mean by 'inline regex', though.

Re: Ruby: Productive Programming Language

Anonymous's picture

> Not sure what you mean by 'inline regex', though.

As in:

if foo =~ /bar/

Thankfully in Ruby you can read that as calling the =~ method of the foo object, with the /bar/ regexp object as an argument, ala the (invalid, but demonstrates what's going on):

if foo.=~('bar'))

Or the more OO (and valid):

if match ='bar').match(foo)

Where you get back a match data object detailing pre/post match, submatches etc.

You can mix it too, since /foo/ is just a shortcut to

if match = /bar/.match(foo)

So although it's possible to write ultra-terse Perl style line noise, it's by no means required, or even particularly common.

Oh, of course....

Anonymous's picture

That's what inline regex's are.

I'm like the proverbial fish that was asked the question "What is water?" and couldn't describe it because it didn't know anything but water.

Re: Ruby: Productive Programming Language

Anonymous's picture

I actually find them pretty handy so that you can tell the scope of a variable 'at-a-glance'.

More than that, many OO programmers use a similar syntactic convention : think about the 'm_' or '_' prefix for data member variables so common in C++ or Java.

That Ruby enforces this in its syntax is really the best thing that could be done.

You are all wrong, VBScript i

Anonymous's picture

You are all wrong, VBScript is the bomb