Published on
· July 10, 2026

The Ruby language: what it is, syntax, and Ruby on Rails

Blog
  • Photo of Henrico Piubello
    Henrico Piubello
    Henrico Piubello
    IT Specialist - Grupo Voitto

    IT Specialist - Grupo Voitto

Ruby is a dynamic, interpreted, object-oriented programming language, created by the Japanese Yukihiro Matsumoto and released in 1995. It combines readable syntax with a focus on programmer productivity, being used to build web applications with Ruby on Rails, automation scripts, and terminal tools.

Ruby-red logo of the Ruby programming language

What is the Ruby language?

Ruby is an open-source, dynamic, object-oriented language, in which everything — numbers, strings, and even classes — is an object. Yukihiro "Matz" Matsumoto created the language in Japan by combining parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp), as described on the official Ruby page.

Matz's stated goal has always been the well-being of those who program. On the same official page, he states: "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy".

In practice, this philosophy translates into a concise and expressive syntax: a Ruby program often reads almost like a sentence in English, with few symbols and no need for semicolons. This characteristic makes Ruby an accessible entry point for beginners and, at the same time, a powerful tool for experienced developers.

What is Ruby for in practice?

Ruby is used to build web development applications with the framework Ruby on Rails, automate repetitive tasks, write software tests, and create command-line tools. The table below summarizes the language's main areas of use:

AreaRuby toolsExample of use
Web developmentRuby on Rails, SinatraApplications like GitHub and Shopify
Task automationRuby scripts, RakeRename files and collect data
Software testingRSpec, CapybaraAutomated tests and BDD
DevOpsVagrant, HomebrewProvision environments and install packages
Static sitesJekyllBlogs and documentation on GitHub Pages
2D gamesGosuPrototypes and indie games

In game development, the Gosu library lets you create complete 2D games in Ruby — a fun way to practice the language. In automation, Ruby scripts handle everything from file management to web data collection, saving hours of manual work.

How to take the first steps in Ruby?

To get started in Ruby, install the language, master the fundamentals (variables, conditionals, loops, and methods), move on to object orientation, and practice with real projects. If you are starting from absolute zero, it is worth reviewing the concepts in our programming logic guide first. The recommended roadmap is:

  1. Install Ruby from the official site ruby-lang.org or with a version manager like rbenv.
  2. Learn the fundamentals: variables, conditional structures, loops, and methods.
  3. Explore object orientation, the foundation of all Ruby code.
  4. Practice with real projects and discover ready-made libraries in RubyGems, the official repository of gems for the language.

Variables in Ruby

Variables in Ruby are used to store data. They are created with a name and receive a value by assignment, with no type declaration:

nome = "Henrico"
idade = 26

puts "Meu nome é #{nome} e tenho #{idade} anos."

In this example, we create two variables, nome and idade, and use them to print a sentence with string interpolation.

Conditional structures in Ruby

Conditional structures allow making decisions in code based on conditions. See an example with if and else:

idade = 18

if idade >= 18
  puts "Você é maior de idade."
else
  puts "Você é menor de idade."
end

In this example, the program checks whether the idade variable is greater than or equal to 18 and prints the appropriate message.

Loops in Ruby

Loops execute a block of code repeatedly. See a while loop:

contador = 1

while contador <= 5
  puts "Este é o loop número #{contador}."
  contador += 1
end

In this example, the while loop runs as long as the contador variable is less than or equal to 5, printing the message on each iteration.

Methods (functions) in Ruby

Functions, called methods in Ruby, are reusable code blocks defined with def:

def saudacao(nome)
  puts "Olá, #{nome}!"
end

saudacao("Renata")
saudacao("Henrico")

In this example, we define a saudacao method that accepts a nome parameter and call it twice with different values.

Object orientation in Ruby: classes, objects, and inheritance

Ruby is a fully object-oriented language: everything in the language is an object. Mastering classes, objects, and inheritance is fundamental to writing idiomatic Ruby code — and it is also the basis for understanding how Ruby on Rails organizes models and controllers.

Classes and objects in Ruby

In Ruby, classes define objects and their properties. See a Pessoa class:

class Pessoa
  def initialize(nome, idade)
    @nome = nome
    @idade = idade
  end

  def apresentacao
    "Olá, meu nome é #{@nome} e tenho #{@idade} anos."
  end
end

The Pessoa class has an initialize constructor that defines the @nome and @idade attributes, plus an apresentacao method that assembles a message with this data. Now, we create objects of this class:

pessoa1 = Pessoa.new("Renata", 24)
pessoa2 = Pessoa.new("Henrico", 26)

puts pessoa1.apresentacao
puts pessoa2.apresentacao

In this snippet, we instantiate pessoa1 and pessoa2 from the Pessoa class and call the apresentacao method of each object.

Inheritance in Ruby

Inheritance lets you create derived classes that take advantage of attributes and methods from the parent class:

class Estudante < Pessoa
  def initialize(nome, idade, curso)
    super(nome, idade)
    @curso = curso
  end

  def apresentacao
    super + " Estou cursando #{@curso}."
  end
end

estudante = Estudante.new("Henrico", 26, "Sistemas de Informação")
puts estudante.apresentacao

In this example, the Estudante class inherits from Pessoa, calls the parent class constructor with super, and overrides the apresentacao method to add the student's course.

Ruby on Rails: the language's web engine

Ruby on Rails is the framework that consolidated Ruby in web development. Created by David Heinemeier Hansson in 2004, Rails follows the "convention over configuration" philosophy: instead of configuring every detail of the application, the developer follows the framework's conventions and focuses on building features.

Rails adopts the MVC (Model-View-Controller) pattern and includes out of the factory everything a web application needs: database access, routing, authentication, and page generation. The official Ruby on Rails guides bring detailed documentation, tutorials, and practical examples for building complete applications.

Products like GitHub, Shopify, and Basecamp were built on Rails and continue to operate at global scale with the framework. If you want to better understand the role of frameworks in modern development, see our article on what frameworks are and how they work.

Is it worth learning Ruby in 2026?

Yes: Ruby maintains an active community, a mature web ecosystem, and growing performance. According to the Stack Overflow Developer Survey 2025, 6.4% of developers used Ruby in the past year and 5.9% worked with Ruby on Rails — smaller numbers than those of JavaScript or Python, but sustained by a solid market of applications in production.

In performance, the evolution is concrete. Ruby 3.4, released on December 25, 2024, brought improvements to the language's JIT compiler. According to Shopify's Ruby infrastructure team on the Rails at Scale blog (January 2025), YJIT 3.4 is about 92% faster than the interpreter in the main benchmarks on x86-64, in addition to consuming less memory than the previous version.

To decide with more context, compare Ruby with other options in our overview of the most used programming languages in the world or explore the Python guide for beginners, the most common alternative for those also considering data science.

Conclusion

Ruby remains one of the most pleasant entry points to programming: the readable syntax reduces the friction of learning, and Ruby on Rails turns that knowledge into real web applications quickly. The language no longer competes for hype with Python or JavaScript, but those who learn Ruby today find a mature ecosystem, heavyweight companies hiring, and an increasingly fast language. Here at CodeCrush, the recommendation is practical: master the fundamentals, build a small project in Rails, and let the code speak for you.

## faq

Frequently asked questions

What is the Ruby language for?

Ruby is mainly used for web development with the Ruby on Rails framework, creating automation scripts, command-line tools, and software testing with RSpec. It also appears in DevOps, with tools like Vagrant and Homebrew, and in static site generators like Jekyll, used on GitHub Pages.

Ruby or Python: which to learn first?

It depends on the goal. Python dominates data science and AI (Artificial Intelligence), while Ruby shines in web development with Rails and automation. Both languages have beginner-friendly syntax. If the goal is to work with web applications in startups and consultancies, Ruby remains a productive choice with an active market.

Is it worth learning Ruby in 2026?

Yes, especially for web development. According to the Stack Overflow Developer Survey 2025, 6.4% of developers use Ruby and 5.9% use Ruby on Rails. Companies like GitHub and Shopify maintain gigantic Rails codebases, and the YJIT compiler has made the language significantly faster in recent versions.

What is Ruby on Rails?

Ruby on Rails is a web development framework written in Ruby, released in 2004 by David Heinemeier Hansson. It follows the convention over configuration philosophy and the MVC pattern, allowing you to build complete applications with less code. GitHub, Shopify, and Basecamp are examples of products built with Rails.

Is Ruby an easy language to learn?

Yes. Ruby was designed by Yukihiro Matsumoto to prioritize the programmer''s happiness and productivity, with syntax close to natural language and no excess of symbols. Concepts like variables, conditionals, loops, and methods are straightforward, and the official documentation on ruby-lang.org offers free guides for beginners.

## continue lendo

Keep browsing

About the author

Photo of Henrico Piubello

Henrico Piubello

IT Specialist - Grupo Voitto · Grupo Voitto

See profile and all articles