# Getting Started with Ruby

#### By Mark Ciotola

First published on August 23, 2019. Last updated on February 15, 2020.

## Introduction

Ruby is a powerful, yet easy-to-use programming language. It can be used to create simple programs and simulations, as well as highly complicated web applications. In fact, many of the leading websites are programmed with Ruby.

## History and Characteristics of Ruby

Computer scientist Yukihiro Matsumoto developed Ruby and first released it in 1995. Ruby draws from Perl, Smalltalk, Eiffel, Ada, and Lisp. [4] When creating Ruby, Matsumoto strived to develop “a scripting language that was more powerful than Perl, and more object-oriented than Python.” [5] In fact, Ruby treats everything as an object. [4] Further, “Ruby is designed to be human-oriented. It reduces the burden of programming. It tries to push jobs back to machines. You can accomplish more tasks with less work, in smaller yet readable code.” [5] The clean, plain-English code of the Ruby language makes learning its basics easy and intuitive. Beginners can start with a free, 20 minute online course at the Ruby Lang site. [4]. Since Ruby is free, open source software [4], it is easily affordable for new areas of social science that may not have a large funding base.

## Conventions

There are several conventions we will use in this book.

Programming code mentioned in text will de denoted by monospacetype. Sometimes they will also be in bold.

Commands entered on the terminal command line shall be monotype after a greater than sign, such as:

> ruby -v

Blocks of programing code will be in their own shaded sections, such as the following, or in areas with line numbers.

# This is a simple Ruby program

fruit = "pear"

puts fruit.to_s

Output from a program shall be indicated in a shaded area.

Pear

## Running Ruby

### Command Line Utility

To use Ruby, the user needs access to their computer’s command line. On Mac OSX, the Terminal application can be used. Console is available for free for Windows. Most Linux applications come with a terminal utility under various names. Or you can use an online Ruby compiler for some somple programs, such as the one from Tutorialspoint.

### Obtaining Ruby

To run the simulation, the user must also have Ruby installed on their machine (for the examples in this article, preferably Ruby 1.9.2 or higher). Some computers have Ruby pre-installed. To find out if your computer has Ruby and its version, on the command line enter:

ruby −v

If you see something similar to the following, then you already have Ruby installed. If not, you will need to install Ruby. Conversely, you can use this website to run Ruby commands in your web browser, although its capabilities are limited.

ruby 1.9.2p290 (2011−07−09 revision 32553) [x86 64−darwin10.7.1]

Otherwise, you need to download it from the following source and install it: http://www.ruby-lang.org/en/

Alternatively, you can try out Ruby without downloading or installing anything by using an online compiler, such as at Tutorialspoint.

## Installing Ruby

To install Ruby, you will need to go to the downloads site.

## References

1. 37Signals, Ruby on Rails. http://rubyonrails.org/, last viewed on 22 March 2013.
2. Blanchard, Paul, Robert L. Devaney and Glen R. Hall, 2002, Differential Equations,second edition. Brooks/Cole.
3. Ruby-Doc.org, Programming Ruby: The Pragmatic Programmer’s Guide. http://www.ruby-doc.org/docs/ProgrammingRuby/, last viewed on 22 March 2013.