Ruby Introduction

What Ruby is, its relationship to Rails, installing it with rbenv/rvm, and hello world with irb.

What is Ruby?

Ruby is a dynamically-typed, interpreted, general-purpose programming language created by Yukihiro "Matz" Matsumoto and released in 1995. Matz designed Ruby explicitly around developer happiness — he's said he wanted a language that felt natural to write, prioritizing human readability and expressiveness over machine efficiency.

Ruby
puts "Hello, Ruby!"

That single line is a complete, runnable Ruby program — no class boilerplate, no explicit main method, no semicolons required.

Ruby and Ruby on Rails

Ruby's most famous use case is Ruby on Rails, a full-stack web framework released by David Heinemeier Hansson in 2004. Rails popularized "convention over configuration" — a philosophy where sensible defaults mean you write far less boilerplate than in comparably-featured frameworks — and was the framework behind the early growth of GitHub, Shopify, Airbnb and Basecamp. It's worth being clear about the distinction: Ruby is the language; Rails is a web framework written in Ruby, in the same way Django is a framework written in Python. You can write Ruby without ever touching Rails (scripts, CLIs, automation), and this track focuses on the language itself.

Why use Ruby?

  • Readability — Ruby code reads close to natural English (5.times { puts "hi" }), which keeps codebases approachable for new team members.
  • Everything is an object — even integers and nil are objects with methods you can call on them, giving the language a small, consistent mental model.
  • Powerful metaprogramming — Ruby lets code define and modify methods and classes at runtime, which is how Rails achieves so much with so little explicit configuration.
  • Mature ecosystem — RubyGems hosts hundreds of thousands of reusable libraries ("gems"), and Bundler manages project dependencies cleanly.
  • Batteries-included standard library — strong built-in support for strings, collections, regular expressions and file I/O without reaching for external packages.

Installing Ruby

Most real projects install Ruby through a version manager rather than a system package, since different projects often need different Ruby versions:

Bash
# rbenv (lightweight, popular choice)
rbenv install 3.3.0
rbenv global 3.3.0

# or rvm (Ruby Version Manager, an older alternative)
rvm install 3.3.0
rvm use 3.3.0 --default
Bash
ruby --version   # e.g. ruby 3.3.0

irb — interactive Ruby

irb (Interactive Ruby) is a REPL (Read-Eval-Print Loop) that ships with every Ruby install — invaluable for quickly trying out an idea:

Bash
$ irb
irb(main):001> 2 + 2
=> 4
irb(main):002> "hello".upcase
=> "HELLO"

Your first Ruby program

Save a file and run it directly with the ruby command — no separate compile step:

Ruby
# hello.rb
name = "World"
puts "Hello, #{name}!"
Bash
ruby hello.rb
Plaintext
Hello, World!

Real-world example

GitHub, Shopify, Airbnb, and Basecamp all built (and in most cases still run) major parts of their platforms on Ruby on Rails. Shopify in particular has publicly invested heavily in Ruby's performance (contributing to YJIT, Ruby's just-in-time compiler) precisely because Ruby's productivity advantages let small teams ship complex e-commerce features quickly.

Common mistakes

  • Assuming "Ruby" and "Rails" are the same thing — Rails is one (very popular) framework written in Ruby, not the language itself.
  • Forgetting Ruby is dynamically typed and expecting a compiler to catch type errors — many bugs that would be compile errors in Java or Rust only surface at runtime in Ruby, which is why the community places heavy emphasis on automated tests.
  • Not using a version manager (rbenv/rvm) and fighting with a single system-wide Ruby version across multiple projects that need different versions.

Interview questions

Q: What's the relationship between Ruby and Ruby on Rails? Ruby is the general-purpose programming language; Rails is a web application framework written in Ruby, in the same relationship as Python and Django. You can use Ruby for many things besides Rails — scripts, CLIs, automation, other frameworks like Sinatra.

Q: Why is Ruby often described as having been designed for "developer happiness"? Its creator, Matz, explicitly optimized the language's design for how natural and pleasant it feels to read and write, rather than purely for raw execution performance or theoretical purity — favoring expressive syntax, sensible defaults, and a consistent "everything is an object" model.