User:Pandawelch/Sandbox

=Ruby=

Ruby is a reflective, dynamic, object-oriented programming language. It combines syntax, semantics and paradigms from multiple other programming languages including Smalltalk, Pyton, List, Dylan and CLU. Ruby is a single-pass interpreted language and is written in C. Ruby was released in 1995 by Yukihiro Matsumoto.

History


Ruby was created by Yukihiro Matsumoto, a Japanese computer scientist. Born in the Osaka prefecture, he was a self-taught programmer until the end of high-school. He graduated from Tsukuba University with an information science degree. He wanted a language that was “… more powerful than Perl, and more object-oriented than Python ."

Ruby was released to the public in 1995 and has grown in popularity since. The TIOBE (The Importance of Being Earnest) index for November 2007 shows Ruby taking ninth most ‘popular’ place. The index is ranked by number of web pages dedicated to each individual programming language, using popular search engines such as Google and Yahoo.

Ruby is regarded as a ‘pure’ object oriented programming language, because everything written in it is treated as an object, from single integers to blocks, classes, prototypes, etc. Ruby, among other ‘pure’ object-oriented languages, was specifically designed to enforce object-oriented methods. Ruby is also referred to as a dynamic and reflective programming language. ‘Dynamic’ is a term used to describe high level programming languages that perform activities at runtime what other languages may not perform at all. ‘Reflective’ means that a computer language is able to be modified while in the process of being executed.

Ruby is a single-pass interpreted language, meaning that code is entered and interpreted one line at a time. There is an online Ruby platform available for free download and distribution at http://www.ruby-lang.org/en/downloads/.

Syntax
The syntax used in Ruby is similar to that of Python and Perl. Class and method definitions are defined by reserved keywords.

Datatypes and Declaration
In Ruby, everything is treated as an object, including classes and integers. See the example below:

By making a method in the class, the user is able to use the   method of the number.

Ruby uses all common datatypes except for the character or  datatype. Datatypes are not set, but re-defined when needed. Everything in Ruby has a second boolean value. Everything in Ruby is true, unless it is an express  or.

In Ruby a symbol prefix to variables indicates their scope. Also, an initial capital letter for a variable indicates a constant. However methods are permitted capital letters. This can result in some confusion.

Conditionals
Ruby makes use of multiple conditionals including


 * , the opposite of If;
 * Short-If, useful for space-saving concatenation.
 * , a switch;
 * Short-If, useful for space-saving concatenation.
 * , a switch;

Other Control Structures
Ruby uses several loop styles. These include :


 * ; and
 * Other complex control structures.
 * Other complex control structures.

Class and Method Declaration
To declare a method, the keyword def is used, with the method name following after, as well as arguments inside a pair of parentheses. A default value for the arguments can be set. Here is an example of a simple greeter class:

The constructor method is named initialize. In this example, if no name is entered then “Hello world!” will be printed to the terminal.

The greeter class  can be called in this way:

Code Examples
Below are some examples of Ruby's extreme object-oriented nature, as well as syntax.

Benefits

 * Ruby is an extremely object-oriented programming language. As the programmer can refer to nearly everything as an object the programmer is able to easily manipulate classes, variables in the same way one would an object.


 * Ruby was designed with simplicity in mind. See below the code required to open the   application in ruby as compared to in C#, a popular programming language.

C#

 * Typical embedded classes and methods in other programming languages are easily modifiable in Ruby. Click here to see an example of manipulating a class to have the   method for an integer or point datatype.

Weaknesses

 * Ruby is extremely complex. Matsumoto has often said that "Ruby is simple in appearance, but is very complex inside, just like our human body ".  The amount of time required to fully understand Ruby is significantly higher that that of other programming languages.


 * Ruby is inferior in terms of speed when compared to compiled languages and other major scripting languages (for example Perl and Python)


 * Lack of strict syntax can result in confusing or unexpected results. An example is the use of parentheses when declaring a method with argument/s, as the parentheses are not required.  However with two or more arguments an ambiguous meaning of code may arise.