About

Ruby is a language of careful balance. Its creator blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming.

He has often said that he is “trying to make Ruby natural, not simple,” in a way that mirrors life.

Building on this, he adds:

Ruby is simple in appearance, but is very complex inside, just like our human body.

Seeing everything as an Object.

Initially, Matz looked at other languages to find an ideal syntax. Recalling his search, he said,
“I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python.”

In Ruby, everything is an object. Every bit of information and code can be given their own properties and actions. Object-oriented programming calls properties by the name instance variables and actions are known as methods. Ruby’s pure object-oriented approach is most commonly demonstrated by a bit of code which applies an action to a number.

Ruby’s Flexibility.

Ruby is seen as a flexible language, since it allows its users to freely alter its parts. Essential parts of Ruby can be removed or redefined, at will. Existing parts can be added upon. Ruby tries not to restrict the coder.

For example, addition is performed with the plus (+) operator. But, if you’d rather use the readable word plus, you could add such a method to Ruby’s builtin Numeric class.


     class Numeric        def plus(x)          self.+(x)        end      end      y = 5.plus 6

 # y is now equal to 11

Ruby’s operators are syntactic sugar for methods. You can redefine them as well.

Blocks: A Truly Expressive Feature

Ruby’s block are also seen as a source of great flexibility. A programmer can attach a closure to any method, describing how that method should act. The closure is called a block and has become one of the most popular features for newcomers to Ruby from other imperative languages like PHP or Visual Basic.

Blocks are inspired by functional languages. Matz said, “in Ruby closures, I wanted to respect the Lisp culture.”

search_engines =
%w[Google Yahoo MSN].map do |engine|
"http://www." + engine.downcase + ".com"
end

In the above code, the block is described inside the do ... end construct. The map method applies the block to the provided list of words. Many other methods in Ruby leave a hole open for a coder to write their own block to fill in the details of what that method should do.

Beyond the Basics.

Ruby has a wealth of other features, among which are the following:

Other Implementations of Ruby.

Ruby, as a language, has a few different implementations. This page has been discussing the reference implementation, in the community often referred to as MRI (“Matz’s Ruby Interpreter”) or CRuby (since it is written in C), but there are also others. They are often useful in certain situations, provide extra integration to other languages or environments, or have special features that MRI doesn’t.

  • JRuby is Ruby atop the JVM (Java Virtual Machine), utilizing the JVM’s optimizing JIT compilers, garbage collectors, concurrent threads, tool ecosystem, and vast collection of libraries.
  • TruffleRuby is a high performance Ruby implementation on top of GraalVM.
  • IronRuby is an implementation “tightly integrated with the .NET Framework”.
  • Cardinal is a “Ruby compiler for Parrot Virtual Machine” (Perl 6).

For a more complete list, see Awesome Rubies.

How to Download?

Installing Ruby

With package managers or third-party tools, you have plenty of options to install and manage Ruby.

For detailed information, please click here.

Reference.

All the documentation in this page is taken from Ruby.