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.
In many languages, numbers and other primitive types are not objects. Ruby follows the influence of the Smalltalk language by giving methods and instance variables to all of its types. This eases one’s use of Ruby, since rules applying to objects apply to all of Ruby.
Ruby’s pure object-oriented approach is most commonly demonstrated by a bit of code which applies an action to a number.
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.
While Ruby often uses very limited punctuation and usually prefers English keywords, some punctuation is used to decorate Ruby. Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables.
These sigils enhance readability by allowing the programmer to easily identify the roles of each variable. It also becomes unnecessary to use a tiresome self. prepended to every instance member.
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”, named after Ruby's creator Yukihiro “Matz” Matsumoto) 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.
The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.
Ruby is a language of careful balance. Its creator, Yukihiro “Matz” Matsumoto, blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming.
Already present at this stage of development were many of the features familiar in later releases of Ruby, including object-oriented design, classes with inheritance, mixins, iterators, closures, exception handling and garbage collection.
After the release of Ruby 0.95 in 1995, several stable versions of Ruby have since been released.
In 1997, the first article about Ruby was published on the Web. In the same year, Matsumoto was hired by netlab.jp to work on Ruby as a full-time developer.
By 2000, Ruby was more popular than Python in Japan.
Official Ruby Language Website, November 14th, 2023.
Ruby Wikipedia, November 16th, 2023.
Ruby GeeksForGeeks, November 17th, 2023.
# Major Ruby Release Dates
#
# You can assign dates with numbers
# to Time.new (year/month/day)
ruby0_95 = Time.new(1995, 12, 21)
ruby1_0 = Time.new(1996, 12, 25)
ruby1_2 = Time.new(1998, 12, 25)
ruby1_4 = Time.new(1999, 8, 1)
ruby1_6 = Time.new(2000, 9, 1)
ruby1_8 = Time.new(2003, 8, 1)
ruby1_9 = Time.new(2007, 12, 25)
ruby2_0 = Time.new(2013, 2, 24)
ruby2_1 = Time.new(2013, 12, 25)
ruby2_2 = Time.new(2014, 12, 25)
ruby2_3 = Time.new(2015, 12, 25)
ruby2_4 = Time.new(2016, 12, 25)
ruby2_5 = Time.new(2017, 12, 25)
ruby2_6 = Time.new(2018, 12, 25)
ruby2_7 = Time.new(2019, 12, 25)
ruby3_0 = Time.new(2020, 12, 25)
ruby3_1 = Time.new(2021, 12, 25)
ruby3_2 = Time.new(2022, 12, 25)
# Demonstrating how even primitive types
# like numbers are objects in Ruby
#
5.times { print "We *love* Ruby -- it's outrageous!" }
# Demonstrating Ruby's Flexibility
#
# You can easily define new methods to Ruby's
# built in classes from your own file
#
class Numeric
def plus(x)
self.+(x)
end
end
y = 5.plus 6
# y is equal to 11
# Knowing the scope of variables is easy in Ruby
#
# The scope can be set manually using punctuation
#
var = "local" # local variables have no denotation
@var = "instance" # instance variables denoted by @
$var = "global" # global variables denoted by $
# For the same reason there are many programming
# languages, there are many different implementations
# of Ruby, each specializing in different things
#
implementations = %w[ JRuby
TruffleRuby
mruby
IronRuby
MagLev
Cardinal
AwesomeRubies ]
# All of the names above are clickable links
# This is not a Ruby function, it is a function of
# this website to allow users to visit the above
# implementations if desired