Ruby Website

Description and History

Ruby is an open-source, interpreted, dynamic, high-level language. It markets itself as natural simple, and easy to read.

Released in 1995, Ruby was developed by japansese hacker Yukihiro “Matz” Matsumoto. Matsumoto's goal was to create an easy scripting language with Object Oriented programming patterns and had great practicality.

To achieve this vision, he combined aspects of Perl, Smalltalk, Eiffel, Ada, and Lisp, to create his vision had functional and imperative programming aspects.

This gave the language some very unique features.

By 2005 Ruby became a highly dominant language largely because of Ruby on Rails.

Translator and Installation

Ruby has several installation options. The first and likely easiest is using your system's package manager. Whether that be apt for Debian based systems, pacman for Arch, homebrew for mac or choco for windows.

apt (Debian/Ubuntu)

$ sudo apt-get install ruby-full

pacman (Arch Linux)

$ sudo pacman -S ruby

Homebrew (macOS)

$ brew install ruby

Chocolatey (Windows)

> choco install ruby

Build from source

As it is open-source, ruby's source files are freely available to build.

$ ./configure
$ make
$ sudo make install

Alternatively, a third-party installer can be used. Further install instructions and options can be found at Ruby's Installation Documentation

Introductory Programs

Hello World

Ruby's hello world is incredibly simple, moreso than even python.

Simply putting the following will print the famous "Hello World" on the terminal

Code:

puts 'Hello world'

Run:

$ ruby hello-world.rb
Hello world

We Really Love Ruby

One unique feature of the language is that everything is an object in Ruby.

This includes the langauge's primitives.

Here is a snippet of code from the about ruby page that demonstrates this.

Code:

5.times { print "We *love* Ruby -- it's outrageous!" }

Run:

$ ruby love-ruby.rb
We *love* Ruby -- it's outrageous!We *love* Ruby -- it's outrageous!We *love* Ruby -- it's outrageous!We *love* Ruby -- it's outrageous!We *love* Ruby -- it's outrageous!

Complex Programs

Backpack

Time-Conversion

Missing Number in Sequence

Quiz-Game

Additional Examples

AandP

Adding

FormattingExamples

HelloWorld

Group Project

GroupProject

GroupProjectTest

Tabular Comparison

Comparisons