Why did I decide to go for Ruby?

I mostly write code in Perl, with C and C++ coming along once in a while. Perl is a dangerously powerful language. You can do most everything in it in a few lines of code. While that is Perl’s best feature, the code written in Perl can get hard to read really easily. The syntax is OK (not as clean as one may expect, although Perl gurus claim that it has a clean syntax), but the fact that a single task can be accomplished in multiple ways (which is Perl’s motto: [TIMTOWTDI] There Is More Than One Way To Do It) coupled with the compactness of code make maintaining of code a nightmare. The point of existence of a scripting language, such as Perl, is to provide a very high-level of programming abstraction to quickly write code to accomplish tasks. Being prone to getting real messy, the syntax Perl has to offer makes Perl a double-edged sword: You can write fast but you can write dirtily. You can write really clear code in Perl, but doing so, of course, takes time to thoughtfully lay out your code in a manner in which it is easy to read and consequently maintain. That sure beats the purpose of a scripting language, I am inclined to think. Write faster yet more difficult to read code; write slower but less difficult to read code. Do you see the point I’m making?

I have not studied Perl’s object oriented (OO) features enough to make a truly informed comment about, but Perl’s OO functionality, well, sucks. If it does not suck, it is stifled and unnatural, and has weird syntax. I have been writing code in Perl for the last two years or so, and I cannot say I have even once used its OO features. That is really OK as long as you are writing system administration scripts and small scripts to do really simple or even moderately complex tasks. But once the length the code runs to starts stretching way beyond the editor screen can manage gracefully, and tasks become complicated and start piling up, you wish Perl had a better interface to its OO features.

I moved to Ruby because I wanted to code in a scripting language that supported properly-designed and thought-out object oriented functionality, with a clean, clear syntax. Ruby just does not come close: It hits the nail right on the head.

Ruby is a true (or, like they call it, pure) object oriented language. Everything is an object. And working with objects is fun and easy. If that was not enough, Ruby extracts most of the best features from a large set of programming languages, both old and new, especially Perl and Python. It borrows its syntax heavily from Perl and Python. The syntax is clean. And I mean, real clean. And flexible. Python has a neat syntax (which is from where Ruby has borrowed its), but it imposes a restriction on the coder: Indentation of code is a must and, therefore, indentation rules should be followed strictly. What Ruby did is to take Python’s syntax, take out the stupid restriction imposed by Python as regards to indentation and throw it away. There you go. You have a clean, neat syntax available that is also very flexible.

If you know Perl and/or Python, you can transition to writing code in Ruby smoothly. Using Ruby, I have the clean syntax of Python, pure OO interface and functionality of many OO languages, and the dangerously powerful features of Perl (especially the all-powerful Regular Expressions) at my disposal. Ruby is like a single package packed up with all the good things from many languages.

There is a lot more to Ruby than meets the eye or than what I have spoken of, but these have been the primary reasons of my moving to Ruby. I still code in Perl. Only, I am now more inclined to do it in Ruby.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s