Ruby Programming 101

Yukihiro Matsumoto
Yukihiro Matsumoto, creator of Ruby

The Ruby programming language was created by a Japanese computer scientist named Yukihiro Matsumoto – known to his adoring fans as “Matz” – in the mid-1990s. Heavily inspired by Perl and Smalltalk, Mr Matsumoto created this dynamic object-oriented programming language because he wanted a language that enhanced productivity and yet was fun to use. Ruby has now become one of the most talked-about programming languages.

While Ruby is primarily an object-oriented programming language, it also supports other programming paradigms such as the procedural and functional paradigms. There are currently several different implementations of Ruby including YARV (yet another Ruby virtual machine), JRuby, HotRuby, Rubinius, IronRuby, MacRuby, etc. These implementations are differentiated by their approaches to compilation and the programming languages used to create their interpreters. The latest stable release, version 1.9, is based on YARV.

Ruby is comparable to the Python programming language in terms of its simplicity and power. Like Python, Ruby employs dynamic typing, which allows the programmer to create a variable without using an explicit declaration statement to set its type. The variable derives its data type based on the value it is assigned.

Ruby is cross-platform, thus a program created using it can be expected to run on any of the major operating systems. It is also open-source, thus the programmer stands to gain from a wide array of freely-downloadable modules which enable the programmer to extend Ruby’s in-built functionality.

Ruby’s simplicity is exemplified by its solution to the classic “Hello World!” programming problem. To print out something on your computer’s command prompt window, the basic Ruby command you need is “puts”. Therefore, to print out “Hello World!” you only require the following command:

puts “Hello World!”

Ruby’s web development framework, Ruby on Rails, has also become immensely popular among web developers. Based on the MVC (model-view-controller) architecture, this framework is under the hood of such popular web applications as Basecamp, Twitter, Hulu and Shopify.

Despite its many strong points, Ruby has previously been criticised for being slower than the likes of Perl and Python, the programming languages that it closely emulates. This is because its original interpreter, CRuby, used to evaluate the source code directly instead of first compiling it to byte-code. This is however expected to change as future official implementations will use the YARV byte-code interpreter which will greatly improve Ruby’s execution speed.

All in all, Ruby is an exciting programming language to learn. It offers simplicity coupled with great power, thus it is no wonder that it has become so popular among programmers nowadays. Download the latest stable release from Ruby-lang.org and try it out.

Subscribe to us on YouTube