Jump to bottom

Ruby (programming language)

From Wikipedia, the free encyclopedia

Jump to: navigation, search
Ruby Ruby logo.svg
Usual file extensions .rb, .rbw
Paradigm multi-paradigm
Appeared in 1995
Designed by Yukihiro Matsumoto
Developer Yukihiro Matsumoto, et al.
Stable release 1.9.1-p376 (December 7, 2009; 3 months ago (2009-12-07))
Preview release 1.9.2 (July 20, 2009; 7 months ago (2009-07-20))
Typing discipline duck, dynamic, strong
Major implementations Ruby MRI, JRuby, YARV
Influenced by Smalltalk, Perl, Lisp, Scheme, Python, CLU, Eiffel, Ada, Dylan, T-RAY
Influenced Groovy, Nu, Falcon, Ioke
OS Cross-platform
License Ruby License
GNU General Public License
Website www.ruby-lang.org

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 was influenced primarily by Perl, Smalltalk, Eiffel, 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.7 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 2010[update], there are a number of complete or upcoming alternative implementations of the Ruby language, including YARV, JRuby, Rubinius, IronRuby, MacRuby and HotRuby, each of which takes a different approach, with IronRuby, JRuby and MacRuby providing just-in-time compilation and MacRuby also providing ahead-of-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] Matsumoto has stated, "I 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]

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 being chosen by Matsumoto in a later email to Ishitsuka.[4] Coral already had a long history as the name of a programming language originating in 1964 at the Royal Radar Establishment in the UK, so it was fortunate that the other name was chosen to eliminate confusion. Matsumoto has later stated that a factor in choosing the name "Ruby" was because it was the birthstone of one of his colleagues.[5]

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]

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 signalled 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.

Ruby on Rails

Around 2005, interest in the Ruby language surged in tandem with Ruby on Rails, a popular web application framework written in Ruby. Rails is frequently credited with making Ruby "famous" and the association is so strong that the two are often conflated by technical laypeople.[9]

Ruby 1.9.1

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

Philosophy

Matsumoto has said that Ruby is designed for programmer productivity and fun, following the principles of good user interface design.[10] He stresses that systems design needs to emphasize human, rather than computer, needs:[11]

“ 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 that he had not applied the principle of least surprise to the design of Ruby,[11] 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.[12]