What is Ruby?


wiseGEEK Writing Contest

In computing, Ruby is a programming language. It appeared in 1995 and was developed by Yukihiro Matsumoto (or "Matz"), a Japanese computer scientist. The creator said that Ruby is designed for 'programmer productivity and fun'. He said that he was influenced by his favorite languages (among them Perl and Smalltalk) to develop Ruby. It is named after the gem-stone Ruby.

In 2007, the most popular programming languages (and the most commercially important) are Java and the C languages. But Ruby is consistently growing in popularity. At May 2007, it made the rank of 10th most popular language, according to the TIOBE Programming Community Index.

Whilst it originally only had strong business support inside Japan, many developers are raving about Ruby. This suggests that it might be an important language in the future. For example developer and consultant Bruce Tate wrote several books touting Ruby as the wave of the future (including the book 'From Java to Ruby') and claiming that Ruby as a language is many times more productive than Java.

In a 2001 interview the creator of Ruby stated: 'Back in 1993, I was talking with a colleague about scripting languages. I was pretty impressed by their power and their possibilities. I felt scripting was the way to go.'

Ruby is often thought of as a scripting language. A 'scripting language' is a language which is 'interpreted' - it can be typed line by line and each line is interpreted into machine code while the program is running. By comparison, other types of languages are often 'compiled', which means that the program is converted completely into executable files before it is run.

Ruby is an open-source language, meaning it's free. It's 'Object-Oriented'. Object-Oriented programming is the standard modern paradigm for writing code. Models of the world are created by dividing everything into separate 'Objects' which are assigned attributes (properties) and methods (behaviours). Message passing between objects enables them to collaborate.

Ruby is touted as having several important advantages over Java and C. The first major advantage is ease of use. The syntax is economical and concise, meaning that Ruby can accomplish more with less verbiage than in Java or C. For example it uses limited punctuation and simple naming conventions. The second major advantage is something known as 'Dynamic Typing'. Java, by comparison uses 'Static Typing', which means that the data type of each variable has to be precisely specified before the program runs. This makes it much less flexible than Ruby.

The Ruby language has additional features which indicate that in some areas it is more advanced than Java or C. Its strength lies in something known as 'Meta-Programming'. This is the ability to write computer programs that write or manipulate other programs. These abilities mean that Ruby could have important applications in the field of artificial intelligence. Reflection, or the ability of a program to reason about itself, is important for artificial intelligence research and Ruby does this very well.

For instance Ruby can change class definitions dynamically (whilst a program is running). Classes are the abstract definition of objects. In Java these definitions have to be fixed before the program is run and cannot be changed. As another example, data (input into programs) can be interpreted as code (the programming language itself).

Another aspect of Ruby which may make it very attractive for those working in artificial intelligence is that it has a 'LISP-like' syntax and some features which are similar to LISP. LISP is the second oldest programming language. Because of its mathematical notation it became the favored language for AI research. LISP was one of Matsumoto’s favorite languages which had an influence on his development of Ruby.

An example of a LISP-influenced feature and also an illustration of the flexibility of Ruby are ‘Blocks’. The programmer can attach closures (short blocks of code) to any method which specifies additional details describing what that method should do. This flexibility or ability to extend Ruby is another commonly touted advantage of the language.

Ruby does have some disadvantages. Because it is not yet as popular as over languages such as Java, it is not as tested or well supported. And as an interpreted language it is generally slower than complied languages.

But its much greater economy and flexibility and its ease of use for meta-programming and reflection makes it ideal for artificial intelligence research. This combined with its growing popularity and its productivity advantages over Java and C suggest that it’s the language of choice for the next generation.

submitted by Marc Geddes