Ruby is an open source, interpreted scripting language for object oriented programming. Interpreted languages are those that can be executed directly from the text file they are stored and do not require compilation. Ruby, which has some of the features of Eiffel, Ada, Perl, Lisp and smalltalk, was created by Yukihiro “matz” Matsumoto. The official release of the language was in 1995.
Ruby is free software that can be downloaded from http://www.ruby-lang.org/en/downloads/. Ruby is portable and is available for various operating systems that include Windows, Linux, UNIX, Macintosh etc.
Language features
- The syntaxes in Ruby are uncomplicated.
- Contains object oriented features like exception handling (like Java or Python), operator and method overloading etc.
- Variables in Ruby can contain any type of data. The datatype is checked at the time of execution. The scope of the variable is indicated by the name of the variable.
- Local variables are written in lower case letters. It may also contain underscore (_). For example, "name".
- Global variables are written with a dollar ($) sign. For example, "$name".
- Instance variables are written with "@" sign. For example, "@name".
- Class variables are written with "@@" symbol. For example, "@@name".
- Constant or Class Name are written with the first letter in capital. For example, "Name".
- Memory is automatically managed in Ruby. An object which is not referred anywhere in the program is automatically cleaned up by the interpreter via the garage collector.
- Ruby contains a mark and sweep garbage collector that works with all Ruby objects. The mark and sweep garbage collection is a two phase collection process:
- In the mark phase the collector scans and marks the objects and references.
- In the sweep phase it deletes the objects that are inaccessible.
- It is not required to maintain reference counts in extension libraries.
- Ruby supports single inheritance (this used only on purpose), polymorphism and multi-threading.
- Ruby supports the concept of modules.