Ruby (programming language)

This is an old revision of this page, as edited by Hajhouse (talk | contribs) at 19:57, 26 December 2001 (copyediting). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Ruby is an object-oriented interpreted programming language with clean syntax. It has its roots in Perl, Smalltalk, Python, LISP and CLU, with Perl being the most important one.


Ruby language features:


  • Obvious syntax
  • Special object-oriented features (mix-ins, singleton methods, renaming, etc.)


Ruby is purely object-oriented: every bit of data is an object, even basic types. Every function is a method. This is similar to Smalltalk but unlike Java and Python. With a few exceptions, every name (variable) in a Ruby program hold a reference to an object, not the object itself.


The language was created by Yukihiro Matsumoto on February 24, 1993. The current stable version is 1.6.5 (25-09-2001). 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 suprise, meaning that the language should be free from the traps and inconsistencies that plague other languages.


Here is a sample of Ruby code (line numbers are not part of the code):



1  string = "Hello world"                     # assign "Hello world" string to variable 'string'

2  another_string = string.gsub(" ", ", ")    # substritute all " " to ", " in variable 'string' and put result into variable 'another_string'

3  another_string += "!\n"                    # append "!\n" ("\n" is newline character) to variable 'another_string'

4  print another_string                       # print variable 'another_string'


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


External References



/Talk