Ruby Programming Language
Ruby is a dynamic, reflective, general purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was initially developed and designed by Yukihiro "Matz" Matsumoto. It is based on Perl, Smalltalk, Eiffel, Ada, and Lisp.
Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management; it is therefore similar in varying respects to Python, Perl, Lisp, Dylan, and CLU.
The standard 1.8.6 (stable) implementation is written in C, as a single-pass interpreted language. There is currently no specification of the Ruby language, so the original implementation is considered to be the de facto reference. As of 2008, there are a number of complete or upcoming alternative implementations of the Ruby language, including YARV, JRuby, Rubinius, IronRuby, and MacRuby, each of which takes a different approach, with JRuby and IronRuby providing just-in-time compilation. The official 1.9 branch uses YARV, as will 2.0 (development), and will eventually supersede the slower Ruby MRI.
History
Yukihiro Matsumoto, the creator of Ruby.
Ruby was conceived on February 24, 1993 by Yukihiro Matsumoto who wished to create a new language that balanced functional programming with imperative programming.[1] According to Matsumoto he "wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language".[2]
[edit] Etymology of the name "Ruby"
The name "Ruby" was decided on during an online chat session between Matsumoto and Keiju Ishitsuka on February 24, 1993, before any code had been written for the language.[3] Initially two names were proposed: "Coral" and "Ruby", with the latter the one being chosen as the name by Matsumoto in a later email to Ishitsuka.[4] Matsumoto has later stated that a factor in choosing the name "Ruby" was because it was the birthstone of one of his colleagues.[5] Later it was recognized that pearl is the birthstone for the month of June, while ruby is the birthstone for July, implying Ruby as the successor of Perl.[2][5]
[edit] First publication
The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.[6][7] Subsequently three more versions of Ruby were released in two days.[3] The release coincided with the launch of the Japanese language ruby-list mailing list which was the first mailing list for the new language.
Already present at this stage of development were many of the features familiar in later releases of Ruby, including object oriented design, classes with inheritance, mixins, iterators, closures, exception handling, and garbage collection.[8]
[edit] Ruby 1.0
Ruby reached version 1.0 on December 25, 1996.[3]
Following the release of Ruby 1.3 in 1999 the first English language mailing list ruby-talk began,[2] which signaled a growing interest in the language outside of Japan. In September 2000, the first English language book Programming Ruby was printed, which was later freely released to the public further widening the adoption of Ruby amongst English speakers.
[edit] Ruby 1.9.1
As of January 30, 2009, the latest stable version of the reference implementation is 1.9.1.
Ruby 1.9.1 introduces many significant changes over version 1.8.6. Some examples are:
* Block local variables (variables that are local to the block in which they are declared)
* An additional lambda syntax (fun = ->(a,b) { puts a + b })
* Per-string character encodings are supported
[edit] Philosophy
Matsumoto has said that Ruby is designed for programmer productivity and fun, following the principles of good user interface design.[9] He stresses that systems design needs to emphasize human, rather than computer, needs:[10]
“ 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 should behave in such a way as to minimize confusion for experienced users. Matsumoto has said his primary design goal was to make a language which he himself enjoyed using, by minimizing programmer work and possible confusion. He has said he had not applied the principle of least surprise to the design of Ruby,[10] but nevertheless the phrase has come to be closely associated with the Ruby programming language. The phrase has itself been a source of surprise, as novice users may take it to mean that Ruby's behaviors try to closely match behaviors familiar from other languages. In a May 2005 discussion on the comp.lang.ruby newsgroup, Matsumoto attempted to distance Ruby from POLS, explaining that because any design choice will be surprising to someone, he uses a personal standard in evaluating surprise. If that personal standard remains consistent there will be few surprises for those familiar with the standard.[11]
Matsumoto defined it this way in an interview[10]:
“ Everyone has an individual background. Someone may come from Python, someone else may come from Perl, and they may be surprised by different aspects of the language. Then they come up to me and say, 'I was surprised by this feature of the language, so Ruby violates the principle of least surprise.' Wait. Wait. The principle of least surprise is not for you only. The principle of least surprise means principle of least my surprise. And it means the principle of least surprise after you learn Ruby very well. For example, I was a C++ programmer before I started designing Ruby. I programmed in C++ exclusively for two or three years. And after two years of C++ programming, it still surprises me. ”
[edit] Features
* Object-oriented, "everything is an object"
* Six levels of variable scope: global, class, class instance, instance, local, and block
* Exception handling
* Iterators and closures (based on passing blocks of code)
* Native, Perl-like regular expressions at the language level
* Operator overloading
* Automatic garbage collecting
* Highly portable
* Cooperative multi-threading on all platforms using green threads
* DLL/Shared library dynamic loading on most platforms
* Introspection, reflection and metaprogramming
* Large standard library
* Supports dependency injection
* Supports object runtime alteration[12]
* Continuations and generators
* Methods can be called without parentheses, making Ruby popular for implementing Domain Specific Languages
Ruby currently lacks full support for Unicode, though it has partial support for UTF-8.