💎

A language tour

The Beauty of Ruby

Code that reads like poetry — expressive, elegant, and joyful to write.

scroll

01 — Expressiveness

Code that reads like English

Ruby was designed for programmer happiness. Matz wanted a language that felt natural — like writing a sentence, not a specification.

natural_language.rb
# Ruby reads like a wish list
5.times { puts "Hello, world!" }

# Asking real questions
age = 17
puts age.odd?     # → true  (predicate methods end in ?)
puts age.between?(10, 20)  # → true

# Unless is built-in
puts "You're a minor" unless age >= 18

# One-liner conditionals feel like prose
puts "Go to bed!" if Time.now.hour > 22

Method names end in ? when they return booleans — the language winks at you.


02 — Blocks & Iterators

Iteration without ceremony

Forget index variables and off-by-one errors. Ruby's blocks make looping a pleasure — and you can pass behaviour around like data.

"Blocks are chunks of code you can hand to a method and say: here, do this when you're ready."

— The Ruby philosophy
blocks.rb
numbers = [3, 1, 4, 1, 5, 9, 2, 6]

# Transform every element
squares = numbers.map { |n| n ** 2 }
# → [9, 1, 16, 1, 25, 81, 4, 36]

# Filter with intent
evens = numbers.select(&:even?)
# → [4, 2, 6]

# Chain it all — pipeline style
result = numbers
  .select { |n| n > 3 }
  .map    { |n| n * 10 }
  .sum
# → 200

&:method_name converts a symbol to a block — the shortest syntax for "call this method on each element."


03 — Open Classes

Everything is alive

In Ruby, every class — even built-ins like Integer or String — can be reopened and extended. The language bends to your domain.

open_classes.rb
class Integer
  def factorial
    return 1 if self <= 1
    self * (self - 1).factorial
  end

  def seconds; self;         end
  def minutes; self * 60;   end
  def hours;   self * 3600; end
end

puts 5.factorial   # → 120
puts 2.hours        # → 7200

class String
  def palindrome?
    self == self.reverse
  end
end

puts "racecar".palindrome?  # → true
puts "ruby".palindrome?     # → false

You didn't "monkey-patch" — you taught the number what a factorial means. That's a different mindset.


04 — Symbols & Hashes

Data structures that delight

Ruby's hashes and symbols feel lightweight and intentional — no boilerplate, just the structure you need.

data.rb
# Modern hash syntax — clean and readable
car = {
  make:   "Porsche",
  model:  "911",
  year:   1973,
  color:  "Guards Red"
}

# Safe navigation — no more nil crashes
user = nil
puts user&.name  # → nil  (not an error!)

# Destructuring with pattern matching (Ruby 3+)
case car
in { make: "Porsche", year: (1970..1979) => year }
  puts "Classic air-cooled from #{year}!"
end
# → Classic air-cooled from 1973!

The &. safe navigation operator is called "lonely operator" — because it guards you from nil in the loneliest of times.


05 — Modules & Mixins

Composition over inheritance

Ruby avoids deep inheritance trees. Instead, modules let you compose behaviour cleanly — mix in exactly what you need.

mixins.rb
module Driveable
  def drive
    puts "#{self.class} is driving!"
  end
end

module Electric
  def charge
    puts "Plugging in… ⚡"
  end
end

class Car
  include Driveable
end

class ElectricCar < Car
  include Electric
end

tesla = ElectricCar.new
tesla.drive   # → ElectricCar is driving!
tesla.charge  # → Plugging in… ⚡

# Enumerable mixin — mix it in, get 50+ methods free
class Playlist
  include Enumerable

  def initialize(songs)
    @songs = songs
  end

  def each(&block)
    @songs.each(&block)
  end
end

pl = Playlist.new(["Bohemian Rhapsody", "Comfortably Numb", "Hotel California"])
puts pl.min    # → Bohemian Rhapsody (alphabetically)
puts pl.sort.first

Including Enumerable and defining one each method unlocks map, sort, min, group_by, flat_map and 40+ more for free.


06 — The Whole Picture

More reasons to love it

🔗

Method Chaining

Every method returns something useful — chains flow left-to-right like a pipeline.

🧬

Everything Is an Object

Even nil, true, and numbers are objects. No primitive types — it's objects all the way down.

🎭

Duck Typing

"If it walks like a duck…" — Ruby cares what an object can do, not what it is.

String Interpolation

"Hello #{name}" — weave values into strings without concatenation noise.

🛠

Rails & Ecosystem

Ruby on Rails showed the world what convention-over-configuration looks like in practice.

😊

Joy First

Matz's goal: "Ruby is designed to make programmers happy." That's still in the language DNA.


07 — Dig Deeper

Learn Ruby

book Programming Ruby 3.3 — 5th Edition Noel Rappin & Dave Thomas The Pickaxe book, fully updated for modern Ruby. Covers pattern matching, Ractors, and everything added through 3.3. book Eloquent Ruby Russ Olsen Teaches you to think in Ruby, not just write it. The book that separates Rubyists from people who merely write Ruby. book The Well-Grounded Rubyist David A. Black & Joseph Leo III Deep dive into the object model, blocks, and metaprogramming mechanics. video GoRails Chris Oliver Screencast series covering Rails and Ruby patterns, trusted by tens of thousands of developers. course The Odin Project Open source curriculum Full-stack web development path built around Ruby and Rails. Completely free.

08 — Notable Contributors

The people behind Ruby

Yukihiro Matsumoto @yukihiro_matz Creator of Ruby. Designed the language around programmer happiness over machine convenience.
David Heinemeier Hansson @dhh Created Ruby on Rails, the framework that catalyzed Ruby's mainstream adoption.
Aaron Patterson @tenderlove Core Ruby and Rails committer, known for deep performance work and being a beloved community figure.
Koichi Sasada @koichisasada Designed YARV, Ruby's virtual machine — the engine that has run every line of Ruby since 1.9.
Maxime Chevalier-Boisvert @Love2Code Lead developer of YJIT, the just-in-time compiler that made Ruby 3 dramatically faster.

09 — Notable Creations

Built with Ruby

GitHub
Version Control Platform
Built on Rails from day one. The infrastructure of open source ran on Ruby.
Shopify
E-Commerce Platform
The largest Rails application in production, serving millions of merchants at global scale.
Basecamp
Project Management
The app DHH built to scratch his own itch — and where convention-over-configuration was born.
Stripe
Payment Infrastructure
The developer-beloved payments API was built on Ruby and helped define a generation of API design.
Airbnb
Home Sharing Platform
Ruby powered the early growth of one of the decade's defining companies.