2.1 Quick History

Yukihiro Matsumoto created Ruby in about 1993. Most people just call him Matz. As a language, Ruby is an interpreted, object-oriented, dynamically typed language from a family of so-called scripting languages. Interpreted means that Ruby code is executed by an interpreter rather than a compiler. Dynamically typed means that types are bound at execution time rather than compile time. In general, the trade-off for such a strategy is flexibility versus execution safety, but we’ll get into that a little more later. Object-oriented means the language supports encapsulation (data and behavior are packaged together), inheritance through classes (object types are organized in a class tree), and polymorphism (objects can take many forms). Ruby patiently waited for the right moment and then burst onto the scene around 2006 with the emergence of the Rails framework. After wandering for ten years in the enterprise jungles, programming was fun again. Ruby is not hugely efficient in terms of execution speed, but it makes programmers very productive.

Interview with Yukihiro (Matz) Matsumoto

I had the pleasure to travel to Matsumotosan’s hometown of Matsue, Japan. We had the chance to have some conversations about the foundations of Ruby, and he agreed to answer some questions for this book.

Bruce:

Why did you write Ruby?

Matz:

Right after I started playing with computers, I got interested in programming languages. They are the means of programming but also enhancers for your mind that shape the way you think about programming. So for a long time, for a hobby, I studied a lot of programming languages. I even implemented several toy languages but no real ones.

In 1993, when I saw Perl, I was somehow inspired that an object-oriented language that combines characteristics from Lisp, Smalltalk, and Perl would be a great language to enhance our productivity. So, I started developing such a language and named it Ruby. The primary motivation was to amuse myself. It was mere hobby at the beginning, trying to create a language that fit my taste. Somehow, other programmers all over the world have felt sympathy for that language and the policy behind it. And it became very popular, far beyond my expectation.

Bruce:

What is the thing you like about it the most?

Matz:

I like the way it makes my programming enjoyable. As a particular technical issue, I like blocks most. They are tamed higher-order functions but open up great possibilities in DSL and other features as well.

Bruce:

What is a feature that you would change, if you could go back in time?

Matz:

I would remove the thread and add actors or some other more advanced concurrency features.

As you read through this chapter, whether or not you already know Ruby, try to keep an eye out for trade-offs that Matz made along the way. Look for syntactic sugar, those little features that break the basic rules of the language to give programmers a little friendlier experience and make the code a little easier to understand. Find places where Matz used code blocks for marvelous effect in collections and elsewhere. And try to understand the trade-offs that he made along the way between simplicity and safety and between productivity and performance.

Let’s get started. Take a peek at some Ruby code:

  >> properties = ['object oriented', 'duck typed', 'productive', 'fun']
  => ["object oriented", "duck typed", "productive", "fun"]
  >> properties.each {|property| puts "Ruby is #{property}."}
  Ruby is object oriented.
  Ruby is duck typed.
  Ruby is productive.
  Ruby is fun.
  => ["object oriented", "duck typed", "productive", "fun"]

Ruby is the language that taught me to smile again. Dynamic to the core, Ruby has a marvelous support community. The implementations are all open source. Most commercial support comes from smaller companies, and that has insulated Ruby from some of the over-reaching frameworks that plague some other kingdoms. Ruby has been slow to catch on in the enterprise, but it’s taking hold now on the strength of its productivity, especially in the area of web development.