Ruby (programming language): Difference between revisions

Content deleted Content added
Ruby Garden
m Automated conversion
Line 1:
'''Ruby''' is an [[object-oriented]] interpreted [[programming language]] with clean syntax. It has its roots in [[Perl programming language|Perl]], [[Smalltalk programming language|Smalltalk]], [[Python programming language|Python]], [[LISP programming language|LISP]] and [[CLU programming language|CLU]], with Perl being the most important one.
 
 
 
Ruby language features:<br>
 
 
 
* Obvious syntax
 
* Basic [[object-oriented]] features
 
* Special object-oriented features:
 
** mixins
 
** singleton methods
 
** renaming
 
** object-specific classes
 
** etc.
 
* [[Operator overloading]]
 
* [[Exception handling]]
 
* [[Iterator|Iterators]] and [[Closure|Closures]]
 
* Perl [[regular expression]] support at [[syntax]] level
 
* [[computer memory garbage collection|Garbage collection]]
 
* [[Dynamic loading]] (depending on the architecture)
 
* High portability (runs on [[Unix]], [[Microsoft Windows]], [[DOS]], OSX, OS/2, [[Amiga]], and many more)
 
* Distributed under an [[open source]] license ([[GPL]] or Artistic)
 
 
 
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 programming language|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.6 (26-12-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):
 
 
Here is a sample of Ruby code (line numbers are not part of the code):
 
 
 
<pre>
string1 = "Hello world" # assign "Hello world" string to variable 'string1'
 
1 string string2 = string1.gsub("Hello world", ", ") # replace all " " by ", " in 'string1', put result # assign "Hello world" string tointo variable 'stringstring2'
string2 += "!
 
" # append "!
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_stringstring2'
4 print another_stringprint string2 # print variable 'another_stringstring2'
 
4 print another_string # print variable 'another_string'
 
</pre>
 
More Ruby code is available in form of sample algorithm implementations in the articles:
 
 
More Ruby code is available in form of sample algorithm implementations in articles:
 
* [[Binary search]]
 
* [[Exponentiating by squaring]]
 
* [[Linear search]]
 
 
 
== External References ==
 
 
 
* Ruby home page: http://www.ruby-lang.org/en/
 
* Ruby FAQ: http://www.rubycentral.com/faq/rubyfaqall.html
 
* Ruby Garden: http://www.rubygarden.org/
 
 
 
 
 
----
[[talk:Ruby_programming_language|/Talk]]
 
/Talk