Ruby, a langage for scripting Web services

The language was locally used before the rails framework appears in 2004 and shares its success with the language itself. It is a framework for building Web application based on that language.

Ruby programming language

It has been designed by Yukihiro "Matz" Matsumoto from 1993 to 1995.
The goal was to program in human style rather than force him adapting its mind to the computer structure. This was firmed up by applying a principle of least surprise that means that the language syntax is always as the programmer does expect it is. But there is also a lot of conventional rules to simplify the programming such as only a way to do a thing (unlike Perl).

Ruby is interpreted (uses bytecode), fully object-oriented and dynamically typed.
Like for Python or PHP, this requires installing the interpreter by the user if you wants to distribute a program, but in fact, it is a whole environment that must be installed, without being sure that everything works. The difference with Java is the size of the standard API of the latter while Ruby depends mainly on third-party libraries.
This is why Ruby is mainly used for business projects, and on servers. It is also aimed at middle-range services, and to scale, one trends to migrate to Java, Node.js and since 2015 to Elixir.

The Ruby syntax inspired Elixir's, running on Beam virtual machine, and Crystal, compiled to LLVM bitcode.

A language simplified by a set of conventions

Thanks to a set of rules, such as the role of capitalization to distinguish constants, the language has been made simpler and more intuitive.
It has been inspired by Perl, Smalltalk and Python.

Variables and constants :

Symbols:

# starts a comment.
[ exp, ... ] enclose arrays.
{ 1 => a, ... } is for a dictionary.

Control structures:

The if structure has elsif and else options.

 if x < 10 then
   print "x less than 10\n"
 else
   print "etc...\n"
 end
The while structure:
 while expr [do]
    ... 
 end          

Function or method:

The definition starts with the def keyword, plus the name and the list or arguments separated by commas, then the statements and is terminated by the end keyword.
The return keyword in the body of the definition allows to return one or several values.

def funcname( arguments )
...statements... return x, y, z
end

Class:

class name
  ...
end

Sample code, Hello world:

do puts "Hello, World!" end  

Scanning the content of an array:

mylist = [ "d", "e", "m", "o" ] 

for i in mylist do
  print i, "\n"
end

Ruby On Rails

Should we choose Ruby On Rails to create online applications?

Like the language itself, this server-side framework has been designed to be simple and intuitive. The main reason that is invoked to justify the choice of ROR is that a working application may be made in a few hours (when one is already familiar with the platform).
It features a number of plugins that increase its possibilities, the "Gems", an integrated test tool, and other tools.

However, its implementation is not so simple for the beginner, unlike PHP, we must know the whole system to start using it and the templating language is rather cabalistic.

ROR owes also its success to its many tools. But time has passed and PHP now has largely evolved. Version 7 is two times faster, is safer. It has now a package manager, Composer, equivalent to RubyGems. It is the same for other platforms: they are equipped with tools equivalent to those of ROR which negates most of its past benefits.

Fans of the platform say it allows for scale on very big websites, yet there is a tendency to migrate to Elixir, a language derived from Ruby, but running on the Erlang platform and the Beam virtual machine, designed for fault tolerance on large sites.

In conclusion, ROR is a safe and stable platform with good documentation, but it is now no more innovative than the alternatives and even late. Furthermore Ruby is little used outside of Rails, so you have to learn a language only to create a website.

See also

Node, Go, Elixir, PHP, what Web app plateform to use?

Tools and documentation

References: The Ruby reference manual.