- byte code interpreter (faster than MRI). Latest 1.9.3 Other versions developed include: - JRuby (JVM version) - Rubinius - Iron Ruby Ruby 2.0 to be released soon(2013?) and frozen Ruby was accepted as a Japanese Industrial Standard (JIS X 3017) in 2011[8] and an international standard (ISO/IEC 30170) in 2012.
but... ... supports functional and imperative programming paradigms Dynamically typed + ‘duck typed’ (C)lean syntax Fun to use! * Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. (Wikipedia)
that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck”.(James Whitcomb Riley) • A style of dynamic typing in which an object's methods and properties determine the valid semantics, rather than its inheritance from a particular class or implementation of a specific interface. • All things are objects in Ruby (see later) - the concept of ‘type’ in the normal sense is not relevant. • Allows polymorphism without inheritance
methods (messages). The object that responds to the method (message) is the receiver. ALL methods in Ruby must have an explicit or implicit receiver. The normal notation is: object.method Methods always return an object The interpretation of the message may be different, depending upon the receiver. This is the essence of duck-typing.
from terminal or app (IDE) Running file code: $ ruby filename.rb Interactive ruby: $ irb Alternative to irb is PRY (much better - a Ruby gem) Use ruby command $ruby (don’t bother!) Note : $ represents the command prompt on Mac
in any class Constants start with a capital letter, including Classes and Modules - these are defined as constants Value constants can be changed dynamically but this produces a warning at run time Constants cannot be declared inside methods Only single inheritance allowed but effective multiple inheritance possible with module ‘mixins’ to classes