Ruby is one of the most popular programming language, it’s a scripting language – like Perl, Python or PHP. Ruby is very easy to learn, it’s also very Human Friendly – so for beginners – it’s a good one to begin with. Ruby has become very popular, mostly in web development, with the Rails framework (most popular and easy to learn web application development framework for ruby).

If you want to learn ruby or may be just started, with Ubuntu (most probably – 12.04 LTS, if you prefer latest stable release), then this post may help you in setting up the ruby environment (on Ubuntu/Linux Mint/other_similar_distributions) and running your first ruby program; you should also checkout the recommended links section for some best free online tutorials (for ruby).

Install Ruby : Getting Ready for Fun

You can install ruby from the system package – using the apt-get or from Synaptic Package Manager but you’re recommended to use RVM (Ruby Version Manager) for installing ruby( instead of  apt-get install ruby1.9.1). RVM is a great tool that allows you to manage multiple versions of ruby – without any hassle, so the rvm way may seems unnecessary at this point but it’s better in long run.

I’ve already explained about installing ruby on Ubuntu/Linux Mint and I’m not going to repeat that again, Just go through this link – installing ruby on rails in Ubuntu 12.04 and follow the steps 1-3 (leave the 4th step because you just want the ruby right now).

Write your first Ruby program

Open the gedit and write the following lines of code

#! /usr/bin/env ruby
puts "Hello, Ruby"
# it just prints Hello, Ruby on the screen (comment)

Now, save the file as hello_world.rb (Ruby source code has the extension .rb ) in your Home directory (~).

Run/Execute Your first ruby program

Open a terminal and type the commands –

cd ~
chmod +x hello_world.rb
ruby hello_world.rb

This video might give you some additional hints if you need.

Recommended Link(s) for Learning Ruby (Free Online Resources)

Learning Rails ?

Check out this interactive video course on Ruby on Rails at Treehouse.

Leave a comment

Your email address will not be published. Required fields are marked *