Ruby From Scratch For Programmers of Other Languages: Installation

Like with any other programming language the first thing you need is the language, a text editor and a compiler. You can download all of these things from here.

Ruby comes with a text editor called SciTE from which you can write and compile programs, it also comes with the Interactive Ruby Console which is a command line program that compiles and runs as you type, the IRB ( it’s weird how th acronym is not IRC instead ) is also used for other things like to download gems (ruby libraries). We won’t be using the IRB until later tutorials.

Now that you’ve downloaded and installed Ruby let’s open up SciTE and write our first program.

puts "Hello world"

The extension for Ruby programs is .rb and you can compile programs by simply hitting F5.

In SciTe the program is typed on the left and when you run the program the results are displayed on the right, like this.

Ruby: Hello world program

So now you know that to show text to the screen you can use “puts” followed by whatever the output is. There is one important thing to note here and that is that yo do not need to type a semicolon at the end of every statement, I did because am used to using languages where the semicolon is mandatory.

Like with some other languages there is more than one way to display text, you could use “print” instead of “puts” for example.

Using print and puts

Like with other programming languages you can use escape characters like , \” and \’ if you want to have quotes inside quotes. You can also other escape characters like \n and \t for new line and tab respectively.

That’s it for this tutorial, I hope you’ve enjoyed making your first ruby program and are eager to learn more, stay tuned.