
Learn Ruby
The language built for developer happiness. Ruby reads like English, runs fast to build, and powers some of the world's biggest web apps through the Ruby on Rails framework. Beautiful, expressive, and genuinely fun to write.
Ruby at a Glance
Clean, expressive syntax with powerful built-in methods. Less code, more done.
name = "Alice"
age = 25
city = "Cape Town"
# String interpolation with #{}
puts "Hello, #{name}!"
puts "Age: #{age}, City: #{city}"
# Multi-line string
message = <<~HEREDOC
Welcome to Ruby!
You are #{age} years old.
Learning from #{city}.
HEREDOC
puts message
# String methods
puts name.upcase
puts name.reverse
puts " hello ".strip$ ruby hello.rb
Hello, Alice! Age: 25, City: Cape Town Welcome to Ruby! You are 25 years old. Learning from Cape Town. ALICE ecilA hello
numbers = [3, 1, 4, 1, 5, 9, 2, 6]
# each β loop over every element
numbers.each { |n| print "#{n} " }
puts
# map β transform every element
doubled = numbers.map { |n| n * 2 }
puts doubled.inspect
# select β keep elements matching condition
evens = numbers.select { |n| n.even? }
puts "Evens: #{evens.inspect}"
# times β repeat N times
3.times { |i| puts "Round #{i + 1}" }$ ruby iterators.rb
3 1 4 1 5 9 2 6 [6, 2, 8, 2, 10, 18, 4, 12] Evens: [4, 2, 6] Round 1 Round 2 Round 3
class Animal
attr_accessor :name, :sound
def initialize(name, sound)
@name = name
@sound = sound
end
def speak
"#{@name} says #{@sound}!"
end
end
class Dog < Animal
def initialize(name)
super(name, "Woof")
end
def fetch(item)
"#{@name} fetches the #{item}!"
end
end
dog = Dog.new("Buddy")
puts dog.speak
puts dog.fetch("ball")
puts dog.name$ ruby classes.rb
Buddy says Woof! Buddy fetches the ball! Buddy
What You'll Learn
Six modules covering everything from puts to classes and blocks.
Variables & Basics
- puts and print output
- String, Integer, Float, Boolean
- String interpolation
- gets and user input
Control Flow
- if / elsif / else / unless
- Ternary operator
- case / when
- Inline conditions
Loops & Iterators
- times, upto, downto
- loop, while, until
- each and map
- select and reject
Methods
- Defining methods with def
- Parameters and defaults
- Return values (implicit)
- Symbols and keyword args
Classes & Objects
- Class and initialize
- Instance variables (@var)
- attr_accessor shortcut
- Inheritance with <
Arrays & Hashes
- Array creation and methods
- Hash (key-value pairs)
- Iterating with each
- Map, select, reduce
Frequently Asked Questions
What is Ruby?
Ruby is a dynamic, object-oriented programming language created in 1995 by Yukihiro "Matz" Matsumoto in Japan. It was designed with developer happiness as the primary goal β the syntax is clean, expressive, and reads almost like English. Everything in Ruby is an object, including numbers and strings.
What is Ruby on Rails?
Ruby on Rails (often just "Rails") is a web framework built in Ruby. It follows the MVC pattern and "convention over configuration" β meaning it makes sensible decisions for you so you write less code. Companies like GitHub, Shopify, and Airbnb were built on Rails and still use it today.
Is Ruby good for beginners?
Yes β Ruby has one of the most beginner-friendly syntaxes of any language. There are no curly braces or semicolons. Code reads naturally. puts "Hello" is all you need to print something. It is great for learning programming concepts without fighting the language.
Is Ruby still relevant in 2026?
Absolutely. Ruby and Rails are very much alive. Shopify β one of the world's largest e-commerce platforms β runs on Rails and actively contributes to it. GitHub, Basecamp, Zendesk and hundreds of startups use Ruby. The job market for experienced Ruby developers remains strong.
What should I learn after Ruby?
Ruby on Rails for web development, Sinatra for lightweight web apps, or RSpec for test-driven development. If you enjoy Ruby's clean syntax, you might also enjoy Python or Elixir. For frontend work, pair your Rails backend knowledge with JavaScript or TypeScript.
Ready to write beautiful code?
Free. No signup. No downloads. Just start.
Start Learning RubyNo account required Β· Always free
The Story of Ruby
Real history, real companies, and an honest look at where Rubyshines and where it doesn't β not just a feature list.
Where it came from
Yukihiro 'Matz' Matsumoto released Ruby in Japan in 1995, explicitly designing it around programmer happiness rather than machine efficiency β he's said openly that he wanted a language that felt natural to write in, blending ideas from Perl, Smalltalk and Lisp. It stayed relatively niche outside Japan until Ruby on Rails changed that entirely in 2004.
How itβs actually used today
Ruby on Rails was the framework behind the first versions of Twitter, Shopify (still runs on Rails today at enormous scale), Airbnb's original platform, and GitHub. Its 'convention over configuration' philosophy let small teams ship complete web applications far faster than the Java or PHP stacks common at the time, which is a big part of why it caught on so quickly in the 2000s startup scene.
Strengths & trade-offs
Ruby's expressive, readable syntax makes it genuinely pleasant to write, and Rails remains one of the fastest ways to go from idea to working web app. It's lost some ground to Node.js and Python in newer projects, partly due to raw execution speed and partly due to shifting hiring trends, though it remains a serious, well-paid skill in existing Rails codebases.
What to learn next
Learning Rails is the near-universal next step after Ruby basics β the language and framework are taught together in almost every course for a reason. SQL is essential alongside it since Rails' ActiveRecord is built entirely around relational databases.