Mar 18, 2015
Table of contents:
Starting out on the journey of learning to code in order to turn your idea into a reality can be daunting. With some many choices and an endless list of decisions to make, it can be overwhelming before you even begin.
One of the most popular first programming languages to learn is Ruby. Ruby is an approachable programming language that can used to build all sorts of projects.
Today is the first of a new series exploring the Ruby programming language.
Ruby is a general-purpose programming language that was created in the mid-1990s by Yukihiro “Matz” Matsumoto. Ruby is a dynamic, object oriented programming language that is ideal for websites, web applications or general scripting tools.
Don’t worry if “dynamic” or “object oriented” don’t mean much to you right now. We will be exploring many of the properties and characteristics of the language in this series.
Some of the largest and most popular websites on the Internet use Ruby as their programming language of choice.
Basecamp use Ruby for their project management application. In fact, Basecamp co-founder David Heinemeier Hansson is the creator of the extremely popular Ruby on Rails framework.
GitHub use Ruby to run the largest code host on the Internet serving over 3.4 million users and 16.7 million repositories.
Shopify use Ruby to run their ecommerce platform that has total gross merchandise volume exceeding $7 billion.
500px use Ruby to run their online photography community that has 2.5 million registered users and over 10 million monthly active users.
So as you can see, Ruby would make an excellent choice if you have big ambitions in turning your idea into a huge online business.
So why should you learn Ruby as a programming language over any of the other choices you have available?
Well, I think Ruby is a good choice of programming language for a number of reasons.
Firstly, Ruby has been established over 20 years now and so it is a mature and stable language. Whilst it can be tempting to jump straight into the hot new thing, learning a mature and trusty programming language like Ruby would be a better choice.
Secondly, there is a wealth of online resources, tutorials, screencasts, books and online courses readily available to help you each step of the way. From beginner to expert, you will find help and guidance for almost any type of problem you stumble across.
Thirdly, Ruby has one of the best online communities in terms of Open Source and commercial software to help build and grow your ideas. With thousands of Open Source packages, it’s highly likely that someone has already solved many of the problems you will encounter. And when it’s time to scale and grow your application and your business, there is a wide range of commercial software and services ready to plug into your application to help you on your path to success.
And finally, if the idea you are working on doesn’t work out, Ruby is one of the most sought-after skills in today’s economy. You won’t struggle to get a job writing Ruby code anywhere in the world with your new found skills and experience. Investing in learning Ruby will be an excellent investment for the rest of your life.
So hopefully I’ve convinced you that learning Ruby is a good idea. Now it’s time to crack on and take our first steps on the journey of becoming a Ruby expert!
The first thing we need to do is to install Ruby on our computers. In order to run Ruby code, your computer needs a way of interpreting your Ruby files.
If you’re running Windows, you will need to download and install RubyInstaller. I’ve never actually done this on a Windows computer, and so I’m not the best person to teach you how to do it. However, I’m sure there will be a tutorial on the Internet somewhere.
If you are running a Linux distribution or OS X, you’re in luck! Ruby is already installed on your computer by default.
However, as you progress on your journey learning Ruby, you will probably find that you will need to run multiple versions of Ruby on the same computer. This comes up when you are working on two different projects that are running two different versions of Ruby.
The best way of running multiple versions of Ruby on the same computer is to use a tool called rbenv.
I won’t go over installing rbenv in this tutorial as there is already an excellent installation guide.
Now that we have Ruby installed on our computer, it’s time to start playing with it.
The easiest way to get started with Ruby is to launch the Interactive Ruby Shell (IRB).
IRB is an interactive program that you can run from the command line. This means you can run ruby code and see instant results, rather than writing code into a file and then manually running it.
To launch IRB, open up your terminal and type:
irb
Your terminal prompt should turn into:
irb(main):001:0>
Now you can write Ruby code into your terminal, it will be evaluated and then you will be returned a response.
To try this out, type the following into IRB:
'hello world'.upcase
You should be returned:
# => "HELLO WORLD"
To get our feet wet with Ruby and IRB we will first take a look at working with numbers.
Ruby makes it really easy to run calculations on numbers:
4 + 9
# => 13
20 - 8
# => 12
12 * 13
# => 156
67 / 4
# => 16
We can also compare two numbers to see which one is bigger:
2 > 3
# => false
5 < 9
# => true
Or if two numbers are equal:
2.eql? 1
# => false
4 == 4
# => true
There are many more things you can do with numbers with Ruby, but for now we will call it a day. Feel free to experiment in IRB by exploring the Numeric documentation.
If you have a burning desire to learn to program, or an idea that you believe could be a really successful business, learning Ruby could be the your first step on the journey to success.
I think Ruby is one of the most approachable programming languages for any newbie coder with ambition to learn and it can be used for all sorts of websites, applications and projects.
If you are new to programming, or just the Ruby language, you’ve come to the right place. Subscribe to my email list so you don’t miss any future tutorials!