Skip to content

Ruby

Ruby is a dynamic, reflective, object-oriented language designed by Yukihiro “Matz” Matsumoto in the mid-1990s with a stated goal of programmer happiness. Everything is an object — 1.class is Integer, nil.class is NilClass — and the language leans hard into expressiveness: blocks, open classes, and a syntax flexible enough to build internal DSLs like Rails’ routes.

It is most often found behind Rails, in DevOps tooling (Chef, Vagrant), and in scripting where a small language with strong string and collection handling wins.

Ruby is a dynamic, strongly-but-implicitly typed, fully object-oriented language with closures (blocks, procs, lambdas), mixins via modules, a mark-and-sweep generational garbage collector, and metaprogramming deep enough to build DSLs. Its reference implementation MRI has a global VM lock, so threads give concurrency but not CPU parallelism; parallelism comes from processes or Ractors. It favours expressiveness over speed, which is why the community optimises developer time and pushes performance work into C extensions or background jobs.

Feature What it means in practice
Everything is an object No primitives; 5.times, "a".upcase, nil.to_a
Dynamic typing Types resolved at runtime; duck typing is idiomatic
Blocks and closures each, map, yield — behaviour passed into methods
Modules and mixins Multiple-inheritance-like reuse without the diamond problem
Metaprogramming define_method, method_missing, send, open classes
Garbage collection Mark-and-sweep, generational, incremental mark
Keyword arguments Explicit, self-documenting APIs since 2.0 (** for splatting)
Symbols Interned, immutable identifiers used as hash keys and method names
Monkey patching Core classes are open — powerful and dangerous
Gems and Bundler Mature ecosystem with lockfile-based dependency resolution

Both are high-level, dynamic, cross-platform, server-side languages with an interactive REPL. The differences are real but narrower than the old table suggests.

Aspect Ruby Python
Typing Dynamic, duck typed Dynamic; optional type hints widely used
Object model Everything is an object (1.class works) Everything is an object too (since Python 3, unified)
Blocks / closures Blocks are first-class syntax; procs and lambdas Lambdas only; no block syntax
Multiple inheritance Not supported; modules provide mixins Multiple inheritance supported, with MRO
Iteration Methods take blocks (list.each { }) for x in list, comprehensions
Significant whitespace No Yes
Packages Gems, Bundler PyPI, pip, venv
Typical niche Web (Rails), DSLs, scripting Data, ML, scripting, web (Django, FastAPI)

The claim that Ruby is “fully object-oriented and Python is not” is outdated: Python 3 unified types and functions into objects. The honest distinction is that Ruby makes the object protocol the primary way to write code — even if is a method call on an object in spirit — while Python treats statements and expressions as first-class syntax.

Page Covers
Ruby Basics Objects, variables, truthiness, symbols, methods, enumerables
Blocks, Procs and Lambdas yield, closures, &, return and arity semantics
Object Orientation Classes, modules, lookup, self, duck typing, method_missing
Garbage Collector Mark-and-sweep, generations, GC.stat, memory bloat
Concurrency GVL, threads, processes, Fibers, Ractors, Sidekiq
Rack The call interface, middleware, Puma, why Rails runs on it
Ruby Interview Questions The classics, with the correct answers

If you are new to Ruby, read in that order. If you are refreshing before an interview, start with Ruby Interview Questions and work backwards into whichever page you failed.

  1. Why does Ruby use a global VM lock, and what would removing it cost?
  2. What problem do modules solve that single inheritance does not?
  3. How does duck typing change the way you design an API?
  4. What is the difference between require and require_relative?
  5. Why is Ruby’s standard library split into default gems and bundled gems?
  • Thinking symbols are just strings. They are interned and immutable, with different semantics.
  • Assuming attr_accessor creates both reader and writer but also public state. It does — that is often a leaky abstraction.
  • Believing Ruby supports multiple inheritance. It does not; modules are not classes.
  • Treating && and and as synonyms. Precedence differs.
  • Assuming classes are closed. They are open, which is why monkey patching works and why load-order bugs happen.