Introduction to Ruby

What Ruby is

Ruby is a dynamic, reflective, interpreted high-level programming language with strong dynamic typing, a garbage collector and an operating-system independent thread implementation. Syntactically it is close to Perl and Eiffel; its object-oriented approach comes from Smalltalk.

Everything is an object, numbers included, so any value answers method calls. Classes stay open: a program may add a method to a class it did not write, which is how many libraries extend the core. Blocks put iteration into the syntax rather than into a library call, and that is how each, map and the rest of the collection methods are written.

Yukihiro Matsumoto, known as Matz, designed the language for programmer happiness. The aim is usually stated as least surprise: a line should do what a reader expects before it runs. Ruby prefers one clear rule over many special cases, which is why short programs stay short and long programs stay readable.

names = ["Ada", "Matz"] names.each { |name| puts "Hello, #{name}" }

Hello, Ada
Hello, Matz

A short history

Matsumoto released Ruby publicly in 1995, after blending parts of his favourite languages: Perl, Smalltalk, Eiffel, Ada and Lisp. For its first decade the language stayed a general-purpose scripting tool, until Ruby on Rails arrived in 2004 and turned it into a common choice for web applications.

Ruby has shipped a new version every December for years, and Ruby 3.0 was one of them: it arrived in December 2020 with a performance goal known as Ruby 3x3, three times faster than Ruby 2.0 on the benchmark suite of the project. Patch releases follow each December version.

Where Ruby is used

Web applications are the best known use: Rails and the smaller frameworks around it hold many production sites. The same language serves automation scripts, internal tools and data pipelines, because a script that reads a file, parses JSON and calls an HTTP endpoint fits on one screen.

Several everyday developer tools are written in Ruby: Homebrew, the package manager of macOS, Vagrant for virtual machines, Chef for configuration management, Jekyll for static sites, Fastlane for mobile releases and CocoaPods for iOS dependencies. That is also why Ruby shows up in CI and CD pipelines: the pipeline runs commands, and some of those commands are Ruby programs.

Implementations

Several implementations run Ruby code:

The language is the same in all of them; the differences are startup time, memory use and access to the host platform. This site runs CRuby.

Versions

A new minor version ships every December, and patch releases follow through the year. Ruby 4.0 arrived in December 2025; this image carries Ruby 3.4.12, from the 3.4 line that arrived in December 2024. Ask the interpreter what it is:

ruby -v

ruby 3.4.12 (2026-10-23 revision 366f5fdc00) +PRISM [x86_64-linux-musl]

The version alone is also available to a Ruby program as the constant RUBY_VERSION, which is handy inside a script or a pipeline check:

ruby -e 'puts RUBY_VERSION'

3.4.12

A one-liner is enough to run real code as well:

ruby -e 'puts (1..5).map { |n| n * n }.sum'

55

RubyGems and Bundler

Shared Ruby code is packaged as gems. The gem command installs a gem from the RubyGems index, and a gem may depend on other gems, so one install can pull in a whole tree of libraries.

Bundler works one level up: a project lists its gems in a Gemfile, Bundler resolves the whole set at once and records the exact versions in Gemfile.lock. Every machine that runs bundle install then gets the same versions, and bundle exec runs a command with them. That lock file is what makes a Ruby project reproducible in a pipeline.

gem -v

3.6.9

Where to go next

The Ruby basics page is the shortest way to a running script: the interactive shell, output and a socket in a few minutes. The Ruby course then walks through the language and the tools around it one lesson at a time, from the first script to a small web API.

If Ruby is not installed yet, start with the install lesson or the guide for your system: Windows, Linux (Ubuntu or Rocky), FreeBSD, macOS or Docker.

Next: Ruby basics: irb, puts and sockets

Article author: Arthur Isaev

Banner image