Ruby (programming language)

This is an old revision of this page, as edited by 80.139.164.194 (talk) at 23:28, 16 August 2003 (New version of Ruby is 1.8.0). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Ruby is a purely object-oriented programming language originally developed for scripting. It combines Perl-like syntax with Smalltalk-like semantics, and also shares some features with Python, Lisp and CLU.

Ruby currently has only one implementation, the Ruby interpreter, although efforts are underway to implement a Ruby front end (called "Cardinal") for the Parrot virtual machine.

Ruby language features:

Ruby is purely object-oriented: every bit of data is an object, including types that are designated "primitive" in impure languages. Every function is a method. This is similar to Smalltalk but unlike Java and Python. Every named value (variable name) in a Ruby program designates a reference to an object, not the object itself.

The language was created by Yukihiro Matsumoto (a.k.a. "Matz") on February 24, 1993. The current stable version is 1.8.0. Note that the name is not an acronym--it is actually a pun on Perl. According to the author, he designed Ruby to follow the principle of least surprise (POLS), meaning that the language should be free from the traps and inconsistencies that plague other languages.

From the Ruby FAQ: If you like Perl, you will like Ruby and be right at home with its syntax. If you like Smalltalk, you will like Ruby and be right at home with its semantics. If you like Python, you may or may not be put off by the huge difference in design philosophy between Python and Ruby/Perl.

Here is a sample of Ruby code:

 # Execute the following block of code 10 times
 10.times {
     # Replace ' ' with ', ' and store in  string1
     string1 = "Hello world".gsub(" ", ",")
     # append "!" to variable 'string1'
     string1 += "!"
     # print variable 'string1', followed by a newline
     puts string1
 }

More Ruby code is available in form of sample algorithm implementations in the articles: