What is Ruby?
What is Ruby?
The Ruby language is rapidly gaining popularity in the US after a long period of incubation in its native Japan. But what is Ruby?
To begin with, Ruby is a scripting language, in the recent tradition of Perl, Python, and Tcl. It allows for a rapid development cycle and the rapid prototyping of applications. It is usually interpreted, requiring no compilation step.
But it is also a general purpose language. Its flexible syntax makes it easy to write a quick three-line script to do a one-time task; but it is also flexible enough to power larger applications of many thousands of lines. Thus it can be compared to Kornshell, but it can also be compared to Java or C++.
It is a radically object-oriented language. The OOP features of Ruby surpass those of Java and C++, approaching Smalltalk in flexibility. Primitive types in Ruby are true objects, so wrappers are never required. Ruby allows singleton methods (added to individual objects rather than classes); this is useful in GUI programming, and in other situations as well. Ruby has open classes in the sense that a program can add to the existing classes at will, making new methods available even to previously-instantiated objects. Code itself can be "objectified" as a code block wrapped in an object. Many of the well-known OO design patterns have already been implemented as Ruby libraries.
Ruby is a dynamic language. Runtime type information (RTTI) is an inherent part of the language, and the reflection API is very advanced, offering a set of hooks, queries, and callbacks that make dynamic programming possible.
Ruby is a Very High-Level Language (VHLL). It has a rich set of built-in classes and methods allowing the manipulation of arrays, strings, hashes, files, and other objects. It allows code blocks to be passed as parameters and borrows CLU's concept of an iterator. It has true closures and code blocks that "remember" the context in which they were created. It has a portable (non-native) threading mechanism that works on Windows as well as Unix platforms.
It is interesting and informative to read what programmers say about using this language. One reports that Ruby is "closer to the way he thinks" than any other language; another says that his pseudocode and his code are virtually identical; and more than one person has said that it makes coding a pleasure rather than a chore. Many individuals have reported that their programs are working sooner than they thought possible, with bugs being fixed quickly, or never even arising in the first place. Those seeking comments (positive and negative) about Ruby can refer to the comp.lang.ruby newsgroup.
The chief shortcoming of Ruby is that it is relatively new. The user community is knowledgeable and helpful, and the numbers are growing daily; but the existing libraries and tools are not yet fully mature. Additionally, the English language documentation has been sparse in the past; but with the publication of The Ruby Way by Sams Publishingthe third English-language book on Ruby, out of six existing so farthis has started to change. The Ruby Way is like a how-to manual arranged by topic, with over 300 sections and many thousands of lines of code presented and explained. It makes a good companion to Teach Yourself Ruby from Sams, which is more oriented to the beginner.