Main Content

Ruby - the second rung of learning the language

Archive - Originally posted on "The Horse's Mouth" - 2014-12-28 11:07:25 - Graham Ellis

When you're learning a programming language - or to program - your text / tutor will almost inevitably start with "Hello World" - a program to display a string of text. That's chosen as the first example as it shows you how to enter and store you program, it shows you any steps necessary to convert it to a runnable program (e.g. C, C++ or Java compilers and/or loaders), and it shows you how to run it. At Well House Consultants, we do "Hello World" too - it's sensible.

But then ... very often you're raced by your course or your tutor from the first rung of the ladder to the tenth, and you had better keep up. For some people, learning on a course at college with a lecture on the language once a week and plenty of time to study in between, this works well. For an intensive course, a book where you have to be self-motivating, or for employees of a company with limited time between lesseons, such a leap is a recipe to get lost very quicky indeed! And alas it doesn't even work all that well for university training, if the shocking drop-out rate is examined.

So we move on from "Hello World" to lots of basics - even for delegates who are experienced in other languages - building up to little read / calculate / write examples, looking at simple conditionals and loops and getting an idea of the feeling and the metrics of the language. And we write the examples in front of the delegates, so that our delegates are shown not only what a program does, but also our mindset as to how we decided to write it that way. The results are available on our website - not necessarily the best of programs, but they do illustrate the basic concepts and some of the "gotcha"s.

As I'm starting the new year with Ruby, I've been through some of our very early Ruby examples this morning, and added sample outputs to our web site from running these programs - including the error messages that you'll get from erroneous programs. One of the big pluses of learning with a tutor / from us is that we'll teach you how to read error messages properly and sort out syntax issues quickly rather than staing at them for hours over (perhaps) a missing quote!

Our Introduction to Ruby module currently has six simple examples - from an extended 'Hell World' through Prompt, read, calculate, write demo.

Moving on to Basic Ruby Language Elements, you can see examples of simple string formatting, various print alternatives, and simple calculations ... as well as some "gotcha" examples such as multiplication replicating a string and rounding error issues on floats.

Ruby is an Object Oriented language, and very early on the course we have a module that introduced Ruby Objects. Please link to the module to see all the examples - or look [here] for one of the example to start you off - and you'll find links to other examples there.

If you want to learn Ruby with us, take a look at our course schedule or public courses. Or if there's a group of you all wanting to learn Ruby at the same time, please check for a private course; typically, such courses are tuned for your organisation's needs, and are more cost effective if you have four or more delegates. It's such a course I'm staring the new year with, and indeed my schedule's looking rather busy with such private group course for the next couple of months. That's unusual after the Christmas break as it's the one time of year that people don't plan ahead. Looks like our formula's working better than ever, and that 2015 will be a busy year!