Ruby
In short
Ruby is a dynamic, object-oriented programming language designed for developer happiness, best known for readable syntax and the Ruby on Rails web framework.
What is Ruby?
Ruby is a general-purpose programming language created by Yukihiro "Matz" Matsumoto in Japan and first released in 1995. Its stated goal is to make programmers happy, so it favors code that reads naturally, like 3.times { puts "hi" }. Ruby became widely known in the mid-2000s through Ruby on Rails, a web framework that popularized the idea of "convention over configuration".
Ruby is dynamically typed and deeply object-oriented: everything, including numbers and nil, is an object with methods. It relies on duck typing, meaning code cares whether an object responds to a method rather than which class it belongs to. Blocks, the chunks of code between do...end or curly braces, are passed to methods like each and map, and metaprogramming lets libraries define methods while the program runs, which is how many expressive mini-languages are built. The standard implementation, CRuby (also called MRI), manages memory with a garbage collector and includes an optional just-in-time compiler for hot code.
Ruby is used mostly for web applications and APIs, as well as scripting, automation and developer tooling. Reading Ruby is often compared to reading plain English: method names can end in ? for questions like empty? or in ! for methods that change the object in place, which makes intent visible at a glance.
Ruby is most often compared with Python. Both are dynamic, garbage-collected, interpreted languages with clean syntax, but Python prefers "one obvious way to do it" and dominates data science and machine learning, while Ruby embraces many ways to express the same idea and is strongest in web development. Ruby code also leans on blocks and method chaining, where Python tends to use comprehensions and explicit loops.
Key takeaways
- Ruby is a dynamic, object-oriented language focused on readability and developer happiness.
- Everything in Ruby is an object, including numbers and
nil. - Blocks and metaprogramming make concise, expressive code possible.
- Its best-known use is web development with the Ruby on Rails framework.
Example
# Blocks pass behavior to methods like select and map
orders = [
{ item: "book", price: 12 },
{ item: "lamp", price: 45 },
{ item: "pen", price: 3 },
]
expensive = orders.select { |o| o[:price] > 10 }
.map { |o| o[:item].upcase }
puts expensive.inspect # ["BOOK", "LAMP"]
puts "Total: #{orders.sum { |o| o[:price] }}" # Total: 60Readers ask
Is Ruby still used today?
Yes. Ruby is actively developed, with a new version released every December, and many long-running web applications and newer startups continue to build on Ruby on Rails.
What is the difference between Ruby and Ruby on Rails?
Ruby is the programming language. Ruby on Rails is a web framework written in Ruby that provides routing, database access, templates and other tools for building web applications quickly.
Is Ruby faster or slower than Python?
Performance depends heavily on the workload and version, and both are generally slower than compiled languages like Go or Java. The choice between them usually comes down to ecosystem, libraries and team preference.
See also
- PythonProgramming Languages, p. 26Python is a general-purpose, dynamically typed programming language known for readable syntax and wide use in data science, automation, and web backends.
- OOPProgramming Fundamentals, p. 40OOP, or object-oriented programming, is a way of structuring code around objects that bundle related data together with the functions that act on that data.
- Garbage CollectionProgramming Fundamentals, p. 23Garbage collection is automatic memory management in which the language runtime finds data a program can no longer use and frees that memory for reuse.
- InterpreterProgramming Fundamentals, p. 30An interpreter is a program that runs source code directly, step by step, instead of first translating the whole program into a separate executable file.
- FrameworkProgramming Fundamentals, p. 20A framework is a reusable foundation of code, tools, and conventions that provides the structure of an application, so developers only fill in their own logic.
- PerlProgramming Languages, p. 22Perl is a mature, dynamic scripting language famous for text processing and built-in regular expressions, long used for system administration and web scripts.
- Ruby on RailsBackend & APIs, p. 40Ruby on Rails is a full-stack web framework for Ruby that favors convention over configuration, so database-backed web apps can be built quickly.
Spotted a mistake or something missing on this page?Suggest an edit