Sticker 015 · Back to Yukihiro Matsumoto’s sticker · Leggi la versione italiana
Before writing Ruby, Yukihiro Matsumoto, known as Matz, wanted a language that made writing scripts and working with objects feel equally natural. In his account, the idea dates to 24 February 1993. Ruby 0.95, the first public version, appeared on Japanese newsgroups in December 1995. The project grew around a design choice that is still easy to recognise: make it easy to express an idea in code. Matz’s account in the official Ruby FAQ.
What makes Ruby object-oriented
In Ruby even numbers and strings are objects on which you can call methods. For example, "sun".upcase returns "SUN". The dot introduces an operation the string knows how to perform. That consistency helps in automation because you can combine operations on strings, numbers and collections without learning a different programming model for each. The project lists Larry Wall’s Perl, Smalltalk, Eiffel, Ada and Lisp among its influences. Ruby’s official introduction.
Blocks show what happens to each item
A block is a piece of code you pass to a method. In this teaching example, ["sun", "moon"].map { |name| name.upcase }, the map method applies the block to each name and returns a new list, ["SUN", "MOON"]. The block says what to do with each item, and the method takes care of going through the collection. The distinction is useful when the same short transformation comes up in several programs.
Four original lines by Matz in the mruby repository
The excerpt below comes from mrblib/numeric.rb in mruby, a lightweight implementation of the language. It is part of the commit in which Matsumoto added Integer#step on 15 September 2012. As long as i is at or below the limit num, the loop passes the current value to the block and increments it by step. The excerpt reproduces the historical code from the commit. Yukihiro Matsumoto’s commit · Original file in the repository · The mruby project.
while(i <= num)
block.call(i)
i += step
end
The repository credits the mruby developers collectively for copyright and releases the code under the MIT licence. MITL file from the same revision.
MIT licence for the excerpt
Copyright (c) 2012 mruby developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Ruby, Rails and the community’s work
The Ruby project publishes the language as free software and documents its licence terms. Ruby on Rails is a web application framework created by David Heinemeier Hansson, which grew out of work on Basecamp. It helped bring Ruby to a wider audience. The ecosystem also grew through people writing libraries, maintaining different implementations and publishing packages on RubyGems. Ruby licence · The Rails Foundation on the origin of Rails · RubyGems.
Featured image. Original AI-generated editorial illustration for this sticker.
Nominate a programmer for the album
Who has made an outstanding contribution to software? We welcome nominations for well-known and lesser-known programmers. Give us a name, a specific project or contribution and sources we can check. An email address is optional and helps if we need clarification. The editors review each nomination before deciding whether to publish it.
