Comparing Ruby with Perl and Python  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Ruby
Written by Michael Neumann   
Wednesday, 21 February 2007
Article Index
Comparing Ruby with Perl and Python  Hot
It took me ..
The operator in Ruby
To make the code shorter ..
Extend the Pint-class
New class Point
Using blocks with methonds
Socket
Perl's regular expressions
C/C extension for Ruby
Module in Ruby

{mos_sb_discuss:50}

I’ll compare Ruby with Perl and Python, because I think they are the most frequently used and best known ones. Ruby has so much advantages against Perl and Python, that I’ll try to mention here as much as possible.



At first I’ll shortly explain what Ruby is: Ruby is a modern, interpreted and object-orientated programming language. It has many similarities with Smalltalk (”everything is an object”, simple inheritance, metaclass-model, code-blocks, garbage-collector, typeless variables, etc. . . ), but takes much of the well formed syntax of Eiffel (or who don’t know that great language, it’s a little bit like Modula or Ada).

Additionally many useful elements from Perl were added (e. g. regular expressions, text-processing, text-substitution, iterators, variables like $ $/ . . . ). Therefore, Ruby is a very good alternative to Perl and Python. The difference between Perl and Ruby is the much easier and better to understand syntax and the easy-to-use ”real” object-orientation. 

Following term which I have found on a Ruby-page expresses the power of Ruby:

Ruby > (Smalltalk + Perl) / 2

Some time ago I asked the author of Ruby, Yukihiro Matsumoto (aka matz), about the history of Ruby and why he developed a new language. Here is his original answer:

”Well, Ruby was born in Feb. 23 1993. At that day, I was talking with my colleague about the possibility of object-oriented scripting language. I knew Perl (Perl4, not Perl5), but I didn’t like it really, because it had smell of toy language (it still has). The object-oriented scripting language seemed very promising.

I knew Python then. But I didn’t like it, because I didn’t think it was a true object-oriented language. OO features are appeared to be add-on to the language. I, as a language mania and OO fan for 15 years, really really wanted a genuine object-oriented, easy-to-use object-oriented scripting language. I looked for, but couldn’t find one.

So, I decided to make it. It took several months to make the interpreter run. I put it the features I love to have in my language, such as iterators, exception handling, garbage collection.

Then, I reorganized the features in Perl into class library, and implemented them. I posted Ruby 0.95 to the Japanese domestic news-groups in Dec. 1995.

Since then, mail lists are established, web pages are formed. Highly active discussion was held in the mail lists. The oldest list ruby-list has 14789 messages until now.

Ruby 1.0 was released in Dec. 1996, 1.1 in Aug. 1997, 1.2 (stable version) and 1.3 (development version) were released in Dec. 1998. Next stable version 1.4 will be shipped this months (June 1999), hopefully.”

As you can see, Ruby was developed, having Perl, Python, Smalltalk and Eiffel (as well as some other languages) in mind. So matz took the best from the above called languages to make a new, better, object-orientated scripting-language.

Unlike Perl and Python Ruby was designed totally object-orientated right from the beginning. So there’s no clumsy syntax for declaring a class like in Perl. That is why many people, myself included, say that Perl isn’t really object-oriented. I agree with Stroustrup, the developer of C++, who once said that a special programming-style (e. g. OOP) is only sufficient supported if the language makes it easy to use this one.

And I do not think that Perl supports sufficient enough the use of the object-oriented paradigm. A big advantage of Ruby is, that it is very easy to learn, and so could perhaps become a language to introduce people into programming or object-orientation (maybe at school instead of the often used language Pascal).



Last Updated ( Sunday, 08 July 2007 )
 
< Prev   Next >