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!
(written 2014-12-28, updated 2014-12-30)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
R103 - Basic Ruby Language Elements [986] puts - opposite of chomp in Ruby - (2006-12-15)
[2287] Learning to program in Ruby - examples of the programming basics - (2009-07-15)
[2296] Variable scope - what is it, and how does it Ruby? - (2009-07-18)
[2613] Constants in Ruby - (2010-02-01)
[2617] Comparing floating point numbers - a word of caution and a solution - (2010-02-01)
[3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
[3430] Sigils - the characters on the start of variable names in Perl, Ruby and Fortran - (2011-09-10)
[3758] Ruby - standard operators are overloaded. Perl - they are not - (2012-06-09)
[3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
[4324] Learning to program - variables and constants - (2014-11-22)
[4504] Where does Ruby load modules from, and how to load from current directory - (2015-06-03)
R102 - Hello Ruby Objects [2603] Ruby objects - a primer - (2010-01-29)
[4009] Clear, concise examples - Ruby classes and objects. - (2013-02-17)
[4580] Easy example - data record to object and object to data record mapping in Ruby - (2015-11-21)
[4581] Thin application, thick objects - keep you main code simple. Example in Ruby - (2015-11-21)
[4673] Separating detailed data code from the main application - Ruby example - (2016-05-16)
R101 - Ruby - Introduction [550] 2006 - Making business a pleasure - (2006-01-01)
[664] Ruby course - oops - it's not happening - (2006-04-01)
[1027] Cue the music, I'm happy. - (2007-01-09)
[1041] Learnt in London - Ruby, Martini, Coral and the Core - (2007-01-17)
[1302] Ruby, Ruby, Ruby. Rails, Rails, Rails. - (2007-08-13)
[1375] Python v Ruby - (2007-10-02)
[1887] Ruby Programming Course - Saturday and Sunday - (2008-11-16)
[2286] New to programming? It is natural (but needless) for you to be nervous - (2009-07-14)
[2607] Answers on Ruby on Rails - (2010-01-30)
[4498] Ruby - where one statement ends and the next begins - (2015-05-26)
Some other Articles
A long and disappointing eveningTemplate / design pattern for C++ constructor and accessorsWhy are people using the TransWilts?Conditionals, loops and methods in Ruby - a primer with simple examplesRuby - the second rung of learning the languageShuffling a list - Ruby and PythonA year of rail memories!Changing what operators do on objects - a comparison across different programming languagesThe changing face of ChristmasChristmas day in Melksham