Sunday, February 17, 2008

What is Ruby?

Ruby is a reflective, object-oriented programming language. It combines syntax inspired by Ada and Perl with Smalltalk-like object-oriented features, and also shares some features with Python, Lisp, Dylan and CLU. Ruby is a single-pass interpreted language. Its main implementation is Free software distributed under an open-source license.

History
The language was created by Yukihiro "Matz" Matsumoto, who started working on Ruby on February 24, 1993 and released it to the public in 1995.

"Ruby" was named after a colleague's birthstone, and in Japanese, is also the word for phonetic glosses of Sino-derived characters. Appropriately, though not intentionally, the name reflects the language's Perl heritage. Pearl is the birthstone of June while the ruby is the birthstone of July (suggesting progression). Although Matsumoto was not aware of it at the time, in typography, pearl and ruby are descriptors in a deprecated hierarchy for type size.

As of December 2005, the latest stable version is 1.8.4. Ruby 1.9 (with some major changes) is also in development.

Philosophy
Matz's primary design consideration is to make programmers happy by reducing the menial work they must do, following the principles of good user interface design. He stresses that systems design needs to emphasize human, rather than computer, needs:

Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something." They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.
Ruby is said to follow the principle of least surprise (POLS), meaning that the language typically behaves intuitively or as the programmer assumes it should. The phrase did not originate with Matz and, generally speaking, Ruby may more closely follow a paradigm best termed as "Matz's Least Surprise", though many programmers have found it to be close to their own mental model as well.

Semantics
Ruby is object-oriented: every bit of data is an object, even classes and types many other languages designate primitive such as integers. Every function is a method. Named values (variables) always designate references to objects, not the objects themselves. Ruby supports inheritance with dynamic dispatch, mixins and singleton methods (belonging to, and defined for, a single instance rather than being defined on the class). Though Ruby does not support multiple inheritance, classes can import modules as mixins. Procedural syntax is supported, but everything done in Ruby procedurally (that is, outside of the scope of a particular object) is actually done to an Object instance named 'main'. Since this class is parent to every other class, the changes become visible to all classes and objects.

Ruby has been described as a multi-paradigm programming language: it allows you to program procedurally (defining functions/variables outside classes makes them part of the root, 'self' Object), with object orientation (everything is an object) or functionally (it has anonymous functions, closures, and continuations; statements all have values, and functions return the last evaluation). It has support for introspection, reflection and meta-programming, as well as support for threads. Ruby features dynamic typing, and supports parametric polymorphism as a matter of course.

According to 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."

Features

  • multi-threading on all platforms
  • DLL/shared library dynamic loading on most platforms.
  • introspection, reflection and meta-programming
  • large standard library
  • supports dependency injection
  • continuations and generators (examples in RubyGarden: continuations and generators)

Ruby currently lacks full support for Unicode, though it has partial support for UTF-8.

About this Terminology
This terminology is from The Wikipedia which is published under the GNU Free Documentation License.

0 comments: