About Ruby

What is Ruby?

“Ruby is a language of careful balance. Its creator, Yukihiro “Matz” Matsumoto, blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming.” *

Simply put, Ruby is a really powerful but flexible programming language. It’s been around since 1995. It’s well developed and popular. You can read more about Ruby in this About section of it’s main site.

Hands down, one of it’s best attributes is the community around it. Thousands of developers around the world use it daily, there’s a huge number of tutorials, answers on coding forums, an insane number of code samples to draw on. Most of all, there’s thousands of libraries that extend the core language and add all sorts of new functionality. But more on that later…

Why Ruby?

Why are we using Ruby in this course? It’s flexible, powerful, easier to read than many other languages, and it’s a great language to learn as a beginner.

The syntax or the way you write code is much more forgiving than other languages

Comparing languages

There’s no better way to illustrate some of the differences than looking at the code

Here’s a comparison of a simple bit of code to print out ‘Hello World’

C++:

#include 
 
int main()
{
    std::cout << "Hello, world!
";
    return 0;
}

Java:

import javax.swing.JFrame;  //Importing class JFrame
import javax.swing.JLabel;  //Importing class JLabel
public class HelloWorld {
    public static void main(String[] args) {
        JFrame frame = new JFrame();           //Creating frame
        frame.setTitle("Hi!");                 //Setting title frame
        frame.add(new JLabel("Hello, world!"));//Adding text to frame
        frame.pack();                          //Setting size to smallest
        frame.setLocationRelativeTo(null);     //Centering frame
        frame.setVisible(true);                //Showing frame
    }
}

Processing:

void setup(){
  println("Hello, world!");
}

Express.js/Node

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

Python:

print "Hello, world!"

Ruby :

puts "Hello, world!"

Python’s pretty good too. But Ruby’s what we’ll use!

Overall:

You’ll notice, the syntax is much more readable and cleaner. It uses less to set up the same program. It doesnt require colons, semi colons or braces to denote structure or actions (Python needs these for conditions and functions).

Learning Ruby

I’ve never programmed before…

Start by trying the interactive Ruby tutorial which will walk you through the basics of Ruby without having to install a single thing.

Give it a try now! - it only takes about 15 minutes to cover the basics.

If you’ve already learned another language

Read this first: https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/

Further reading:

×

Subscribe

The latest tutorials sent straight to your inbox.