iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Intro

Ruby is a dynamic, expressive language designed for programmer happiness. Powers Rails — still one of the fastest ways to ship a web app.

Ruby — what it is

EXAMPLE
# ===== The values =====
# - Designed for readability and expressiveness
# - Everything is an object
# - Strong metaprogramming and DSL story
# - Rails: the framework that put Ruby on the map; still ergonomic in 2026

# ===== Hello, world =====
puts 'hello, world'

# Run: ruby hello.rb

# ===== A taste of the language =====
[1, 2, 3, 4].select(&:even?).map { |n| n * n }
# => [4, 16]

class User
  attr_accessor :name, :email
  def initialize(name:, email:)
    @name = name; @email = email
  end
  def to_s = "#{@name} <#{@email}>"
end

u = User.new(name: 'Alex', email: 'a@x.io')
puts u

# ===== A tiny Sinatra app =====
# Gemfile
#   gem 'sinatra'
require 'sinatra'
get '/healthz' do
  content_type :json
  '{"ok":true}'
end

# ===== Rails one-liner =====
#   gem install rails
#   rails new shop
#   cd shop && bin/rails generate scaffold Product name:string price:decimal
#   bin/rails server
# In 30 seconds you have a working CRUD app.

# ===== When Ruby wins =====
# - Web apps and APIs you want to ship FAST
# - Internal tools and admin dashboards
# - DSLs (Rake, Chef, Capistrano) — Ruby is unrivalled here
# - Refactor-heavy domains (RSpec + clear syntax accelerate change)

# ===== When Ruby hurts =====
# - CPU-bound work (use a different runtime)
# - Strict static typing requirements (Sorbet / RBS help but it's bolt-on)
# - Cold-start sensitive workloads (boot time non-trivial)

# ===== Patterns to internalise =====
# - Blocks + iterators instead of explicit loops
# - Symbols for keys + identifiers; strings for human-facing text
# - Frozen strings on hot paths (# frozen_string_literal: true)
# - Tests with RSpec + factory-bot; or Minitest if you like simple

# ===== Pitfalls =====
# - method_missing magic that no one can grep for
# - Long monkey patches in libraries that affect unrelated code
# - Treating nil as falsy is correct; treating '' or 0 as falsy is WRONG (only nil/false are)
# - Memory creep from string allocation; freeze where it matters

Why it matters

Ruby still earns its place by reading like English and getting out of the way. Rails ships features in evenings; the testing culture is strong; metaprogramming gives you DSLs. The trade-offs are well known — but few stacks let a small team build a real product as quickly.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# Ruby: dynamic, OO. Created by Matz in 1995.
# Rails (2004) put it on the map.
Try it Yourself »

Exercise

Print to stdout.

'Hello, Ruby'

Test yourself

Q1. Ruby was created by…
Q2. Ruby is…
Q3. Ruby on Rails first shipped in…

Discussion

Loading…