Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Converting to Ruby? Start here


It's an open source programming language.

Why do we need another programming language? Well - perhaps we don't actually need one, but ruby's 'metrics' are a bit different to other languages so it fits well into places others have to be kludged, and it's not got a long history to which all new releases must remain faithful / compatible.


According to the Ruby web site (but re-written by myself to show you the benefits as well as the features):

Ruby has simple syntax. Easy to learn and, fast to interpret.

Ruby has exception handling to make it easy to handle errors.

Ruby's operators are syntax sugar for the methods and you can redefine them.

Ruby is a complete, full, pure object oriented language: OOL. All data in Ruby is an object. This keeps it very clean and gives great flexibility.

Ruby's OO is carefully designed to be both complete and open for improvements. Example: Ruby has the ability to add methods to a class, or even to an instance during runtime. So, if needed, an instance of one class *can* behave differently from other instances of the same class.

Ruby features single inheritance only, intentionally to avoid excess complexity and poor design. However,Ruby knows the concept of modules (collections of methods) which classes can import and get all its methods for free. Multiple inheritance (the alternative) is a nightmare well avoided.

Ruby features blocks in its syntax (code surrounded by '{' ... '}' or 'do' ... 'end'). These blocks can be passed to methods, or converted into closures.

Ruby features a true mark-and-sweep garbage collector. Efficient reuse of memory and dynamic allocation of memory only when you need it.

Writing C extensions in Ruby is easier than in other languages.

Integers in Ruby can (and should) be used without counting their internal representation. No overflow problems.

Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables. Examples: simple 'var' = local variable, '@var' = instance variable, '$var' = global variable.

Ruby can load extension libraries dynamically if an OS allows.

Ruby features OS independent threading.

Ruby is highly portable; it works on Linux, most UNIX, Windows, MacOS, DOS, BeOS, OS/2, etc.

See: http://www2.ruby-lang.org/en/20020101.html


Line end is end of statement

Where a statement is clearly not completed on one line, it is carried on to another.

A ; can force a new statement


Case sensitive names.

No typing - everything is an object

"Bare" words - at least for local variables - no leading $ @ % or anything else

Variables appear automatically, but not assumed to start at 0 or empty - they must be initially assigned.


# through to line end. Applies from start of line of from within a line where # is a new token in the base context.


use irb - interactive ruby, supplied with the distribution

earth-wind-and-fire:~/ruby/r101 grahamellis$ irb
irb(main):001:0> 5
=> 5
irb(main):002:0> y = 6
=> 6
irb(main):003:0> y * 7
=> 42
irb(main):004:0> exit
earth-wind-and-fire:~/ruby/r101 grahamellis$


So much for the theory and introduction - let's see a sample program:

# Single quote - literal string
print 'Hello World\n'

# Multiple quote - \ translation
print "Hello World\n"

# Gets to read from keyboard
print "Please enter your name: "
# assignment creates a variable; gets is an operator?
stuff = gets

# chomp to strip off last character - RETURNS a string
lessstuff = stuff.chomp

print lessstuff," and fries\n"

How does that run?

earth-wind-and-fire:~/ruby/r101 grahamellis$ ruby hello.rb
Hello World\nHello World
Please enter your name: Graham
Graham and fries
earth-wind-and-fire:~/ruby/r101 grahamellis$

There's clearly a lot more to explain there, but you'll see the basis of an easy, short language where you can write a lot of effective and short code quickly ... with the important bonus that the code is almost 'naturally readable' even to newcomers to the language.

Here are some terms you'll come across time and again with Ruby that we haven't mentioned yet:


You'll come across references to "pragmatic" programming. The following are definitions of pragmatic in general (non-programming) use:

1. Dealing or concerned with facts or actual occurrences; practical.

2. Relating to or being the study of cause and effect in historical or political events with emphasis on the practical lessons to be learned from them.

What does that mean in programming terms - to quote David Thomas and Andrew Hunt, Authors of "Programming Ruby, the Pragmatic Programmer's Guide",

Our job is to solve problems, not spoon-feed compilers, so we like dynamic languages that adapt to us, without arbitrary, rigid rules. We need clarity so we can communicate using our code. We value conciseness and the ability to express a requirement in code accurately and efficiently. The less code we write, the less that can go wrong. (And our wrists and fingers are thankful, too.)

We want to be as productive as possible, so we want our code to run the first time; time spent in the debugger is time stolen from the development clock. It also helps if we can try out code as we edit it; if you have to wait for a 2-hour make cycle, you may as well be using punch cards and submitting your work for batch compilation.

We want a language that works at a high level of abstraction. The higher level the language, the less time we spend translating our requirements into code.

See: http://www.ruby-doc.org/docs/ProgrammingRuby/


"Ruby on Rails" is a framework for web based, database driven applications. In a nutshell, it provides the programmer with a very effective tool with which to provide the functionality needed by web users (and site and data administrators too) in accessing, searching and modifying information stored in SQL tables. As you would expect from the name, the programatic elements of RoR are written in Ruby, and if you're going to be a Ruby on Rails developer, you'll want to start off by learning something of the Ruby language.


This page is taken from our 2 day Ruby programming course that you can book through this site. And if you're wanting to browse further material but aren't serious enough about it to have the justification for a course, you'll find plenty of other material on this site and on links elsewhere.

See also Ruby course - UK, Ireland, Europe

Please note that articles in this section of our web site were current and correct to the best of our ability when published, but by the nature of our business may go out of date quite quickly. The quoting of a price, contract term or any other information in this area of our website is NOT an offer to supply now on those terms - please check back via our main web site

Related Material

Ruby - Control Structures
  [960] - ()
  [962] - ()
  [985] - ()
  [995] - ()
  [1163] - ()
  [1220] - ()
  [1582] - ()
  [1587] - ()
  [1696] - ()
  [1738] - ()
  [1870] - ()
  [1887] - ()
  [1891] - ()
  [1904] - ()
  [2287] - ()
  [2471] - ()
  [2619] - ()
  [2711] - ()
  [2892] - ()
  [2975] - ()
  [3156] - ()
  [3158] - ()
  [3159] - ()
  [3200] - ()
  [3253] - ()
  [3254] - ()
  [3397] - ()
  [3422] - ()
  [3619] - ()
  [3620] - ()
  [3769] - ()
  [4322] - ()
  [4323] - ()
  [4370] - ()
  [4402] - ()
  [4503] - ()
  [4504] - ()
  [4674] - ()

Ruby - General
  [2104] - ()
  [2227] - ()
  [2504] - ()
  [2605] - ()
  [2826] - ()
  [2866] - ()
  [3158] - ()
  [3799] - ()
  [4294] - ()
  [4583] - ()

resource index - Ruby
Solutions centre home page

You'll find shorter technical items at The Horse's Mouth and delegate's questions answered at the Opentalk forum.

At Well House Consultants, we provide training courses on subjects such as Ruby, Lua, Perl, Python, Linux, C, C++, Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer) many questions, and answers to those which are of general interest are published in this area of our site.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/solutions/ruby-con ... -here.html • PAGE BUILT: Wed Mar 28 07:47:11 2012 • BUILD SYSTEM: wizard