Ruby Installation
What is Ruby?
Ruby is a cross-platform, interpreted and an object-oriented language. Ruby has been designed on the Principle of Least Surprise - Matz says "I wanted to minimize my frustration during programming, so I want to minimize my effort in programming. That was my primary goal in designing Ruby. I want to have fun in programming myself. After releasing Ruby and many people around the world got to know Ruby, they said they feel the way I feel. They came up with the phrase the principle of least surprise."
The year 2004 saw a massive surge of interest in Ruby, with the introduction of the Ruby on Rails Web application framework by David Heinemeier Hansson.
Yukihiro Matsumoto, commonly known as 'Matz' created the Ruby language in 1993. An interview with him in 2001, talks about the history of Ruby. Matz's "The Philosophy of Ruby" is another good read.
How Ruby can help you, in more detail
In David Black's book, 'Ruby for Rails', he mentions that a solid grounding in Ruby can serve you, as a Rails developer, in four ways:
- By helping you know what the code in your application (including Rails boilerplate code) is doing
- By helping you do more in, and with, your Rails applications than you can if you limit yourself to the readily available Rails idioms and techniques (as powerful as those are)
- By allowing you to familiarize yourself with the Rails source code, which in turn enables you to participate in discussions about Rails and perhaps even submit bug reports and code patches
- By giving you a powerful tool for administrative and organization tasks (for example, legacy code conversion) connected with your application
Downloading Ruby
As an open source language, Ruby has been ported to run on many different computer platforms and architectures. This means that if you develop a Ruby program on one machine, it's likely you'll be able to run it without any changes on a different machine. You can use Ruby, in one form or another, on most operating systems and platforms.
Though I talk about Ruby on a Windows platform, these notes are appropriate for Linux/Mac users as well.
The simplest way to get Ruby installed on a PC is by using the Ruby Installer for Windows. This will download ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]. After you have downloaded this, double-click this file and install Ruby on your PC, accepting all the defaults. After you have installed your Ruby software, the System Environment Variable path is already set to point to the bin folder of Ruby. Always check whether this has been set properly or not. If not, set it externally.
Click here for more information about this download.
You can use any editor you like, as long as it's a plain-text editor and not a word processor) and a directory (a.k.a. a folder) in which to store your Ruby program files. The folder is separate from other work areas so that you can keep track of your practice program files.
You'll find two executables in the Ruby Windows distribution. ruby.exe is meant to be used at a command prompt (a DOS shell), just as in the Unix version. For applications that read and write to the standard input and output, this is fine. But this also means that anytime you run ruby.exe, you'll get a DOS shell even if you don't want one - Windows will create a new command prompt window and display it while Ruby is running. This may not be appropriate behavior if, for example, you double-click a Ruby script that uses a graphical interface (such as Tk), or if you are running a Ruby script as a background task or from inside another program. In these cases, you'll want to use rubyw.exe. It is the same as ruby.exe except that it does not provide standard in, standard out, or standard error and does not launch a DOS shell when run.
Do note that these instructions assume that you are going to use a Windows platform. For installation on other platforms, you can refer here.
Ruby Programming Environment
Let's assume that you have Windows operating system and have installed Ruby in the folder c:/ruby, then the installation creates a number of sub-folders. Some of these folders are:
c:/ruby/bin is where the Ruby executables (including ruby and irb) have been installed.
c:/ruby/lib/ruby/1.9.1 you'll find program files written in Ruby. These files provide standard library facilities, which you can require from your own programs if you need the functionality they provide.
c:/ruby/lib/ruby/1.9.1/i386-mingw32 contains architecture-specific extensions and libraries. The files in this directory generally have names ending in .so or .dll (depending on your platform). These files are C-language extensions to Ruby; or, more precisely, they are the binary, runtime-loadable files generated from Ruby's C-language extension code, compiled into binary form as part of the Ruby installation process.
c:/ruby/lib/ruby/site_ruby folder is where you and/or your system administrator store third-party extensions and libraries. Some of these may be code you yourself write; others are tools you download from other people's sites and archives of Ruby libraries.
c:/ruby/lib/ruby/gems is the Ruby-Gems packaging system (more on this later).
Note: The Ruby Logo is Copyright (c) 2006, Yukihiro Matsumoto. I have made extensive references to information, related to Ruby, available in the public domain (wikis and the blogs, articles of various Ruby Gurus), my acknowledgment and thanks to all of them. Much of the material on rubylearning.com and in the course at rubylearning.org is drawn primarily from the Programming Ruby book, available from The Pragmatic Bookshelf.
