kids encyclopedia robot

Ruby (programming language) facts for kids

Kids Encyclopedia Facts
Quick facts for kids
Ruby
Ruby logo.svg
Paradigm Multi-paradigm: functional, imperative, object-oriented, reflective
Designed by Yukihiro Matsumoto
Developer Yukihiro Matsumoto, et al.
First appeared 1995; 30 years ago (1995)
Stable release
3.4.5 Edit this on Wikidata / 15 July 2025; 44 days ago (15 July 2025)
Typing discipline Duck, dynamic, strong
Scope Lexical, sometimes dynamic
Implementation language C
OS Cross-platform
License Ruby License
Filename extensions .rb, .ru
Major implementations
Ruby MRI, TruffleRuby, YARV, Rubinius, JRuby, RubyMotion, mruby
Influenced by
Ada, Basic, C++, CLU, Dylan,
Eiffel, Lisp, Lua, Perl, Python, Smalltalk
Influenced
Clojure, CoffeeScript, Crystal, D, Elixir, Groovy, Julia, Mirah, Nu, Ring, Rust, Swift

Ruby is a special kind of computer language called a general-purpose programming language. It was created to make writing computer programs easier and more fun. In Ruby, almost everything you work with is an object. This includes even simple things like numbers.

Ruby was developed in the mid-1990s by a person named Yukihiro "Matz" Matsumoto in Japan. It is an interpreted language, meaning a program called an interpreter runs the code directly. It is also a high-level language, which means it's easier for humans to understand than low-level languages. Ruby can be used for many different programming styles, like object-oriented programming, where you organize code around objects.

History of Ruby

How Ruby Started

Yukihiro Matsumoto, also known as "Matz," first thought about creating Ruby in 1993. He wanted a programming language that was easy to use and focused on objects. He knew other languages like Perl and Python, but he felt they weren't truly object-oriented.

Matz wanted a language that was genuinely object-oriented and simple to use. He imagined Ruby as a core language like Lisp, but with an object system similar to Smalltalk. It also had useful features like Perl.

The name "Ruby" was chosen during an online chat on February 24, 1993. Matz picked it because a friend's birthstone was a ruby.

Early Versions of Ruby

The very first public version of Ruby, called Ruby 0.95, was announced on December 21, 1995. Soon after, more versions were released. At this early stage, Ruby already had many features it's known for today. These included object-oriented programming, classes that could inherit features from others, and garbage collection (which helps manage computer memory).

In 1997, the first article about Ruby appeared online. Matz then started working on Ruby full-time. By 1999, the first English-language mailing list for Ruby began, showing that people outside Japan were becoming interested. The first book about Ruby was also published in Japan that year.

By 2000, Ruby was more popular than Python in Japan. The first English book, Programming Ruby, was released in September 2000. This helped many more English speakers learn about Ruby.

Ruby 1.8 and 1.9 Updates

Ruby 1.8 was released in August 2003 and was used for a long time. Even though it's an older version, some code still uses it.

Around 2005, Ruby became much more popular because of Ruby on Rails. This is a special tool, called a web framework, that helps people build websites using Ruby. Rails really helped more people discover and use Ruby.

Ruby On Rails Logo
The logo for Ruby on Rails, a popular web framework built with Ruby.

Later, with Ruby 1.9.3, released in October 2011, Ruby changed its licensing. This version also brought some changes that made it harder for older Ruby 1.8 programs to work with it.

Ruby 2 Updates

Ruby 2.0 came out on February 24, 2013. It was designed to work almost perfectly with Ruby 1.9.3.

Later versions of Ruby 2, like Ruby 2.2.0, brought many improvements. These included making programs run faster and better ways to handle computer memory. It also added support for Unicode, which helps computers understand many different languages and symbols.

Ruby 2.3.0 added even more speed improvements and helpful features. One cool feature was the new safe navigation operator (&.). This helps prevent errors when you're trying to access information that might not be there. For example, instead of checking if something exists multiple times, you could just use obj&.foo&.bar. Another useful addition was the did_you_mean tool, which suggests corrections if you type something wrong.

Ruby 2.4.0 made things like looking up information in lists and accessing variables even faster. It also combined two types of numbers, Fixnum and Bignum, into one Integer class.

Ruby 2.5.0 made it easier to organize code and transform data. It also made many parts of Ruby run faster.

Ruby 2.6.0 introduced an experimental just-in-time compiler (JIT). This is a tool that can make Ruby programs run much faster by turning parts of the code into machine language while the program is running.

Ruby 2.7.0 added experimental features like "pattern matching," which helps you write cleaner code for checking data. It also improved the interactive Ruby tool (REPL).

Ruby 3 Updates

Ruby 3.0.0 was released on December 25, 2020. A big goal for Ruby 3.0 was to make programs run three times faster than Ruby 2.0. This goal is called "Ruby 3x3." To help achieve this, Ruby 3 included new JIT compilers like MJIT and later YJIT. These compilers are still experimental and need to be turned on.

Ruby 3.0 also aimed to improve concurrency, which means running multiple tasks at the same time. New tools like Fibre Scheduler and Ractor help with this. Ractor is designed to be safe for running many tasks at once by sending messages instead of sharing data directly.

Ruby 3.0 also introduced RBS, a special language to describe the types of data in Ruby programs. This helps with static analysis, which means checking code for errors before it even runs.

Ruby 3.1 was released on December 25, 2021. It included YJIT, a new experimental JIT compiler developed by Shopify. This compiler helps make real-world business applications run faster. A new debugger was also added to help programmers find and fix mistakes in their code.

Ruby 3.2 came out on December 25, 2022. It added support for running Ruby inside a WebAssembly environment, which is useful for web applications. It also improved how regular expressions work, making them faster and safer. This version also included helpful features like syntax suggestions and error highlighting to make coding easier.

Ruby 3.3 was released on December 25, 2023. It brought important improvements, including a new parser called Prism, and a pure-Ruby JIT compiler called RJIT. The YJIT compiler also got major speed boosts. These changes help Ruby programs run more efficiently and make it easier for developers to use the language.

Ruby 3.4 was released on December 25, 2024. This version added new features like the `it` block parameter reference and made Prism the default parser. It also improved YJIT and introduced a modular Garbage Collector.

What Ruby is Like

Yukihiro Matsumoto
Yukihiro Matsumoto, the creator of Ruby, designed the language to be fun and productive for programmers.

Matz, the creator of Ruby, said that he designed Ruby to make programmers productive and happy. He believes that computer systems should be designed for people, not just for machines. He said, "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language."

Matz wanted to create a language that he himself would enjoy using. He tried to make it simple and reduce confusion for programmers.

Ruby is an object-oriented language. This means that every piece of data you use in Ruby is an object. Even numbers and true/false values are objects. Because everything is an object, everything in Ruby has special built-in actions called methods. When you want to do something, you "call a method" on an object.

Ruby is also a multi-paradigm programming language. This means you can use it in different ways. You can write code that focuses on steps (procedural), or on objects (object-oriented), or on functions (functional). Ruby is very flexible!

Key Features of Ruby

Ruby has many features that make it powerful and easy to use:

  • It is completely object-oriented, with inheritance (where classes can get features from other classes) and mixins (where classes can include features from different modules).
  • It uses dynamic typing, meaning you don't have to tell Ruby what type of data a variable will hold beforehand.
  • Almost everything in Ruby is an expression, which means it produces a value.
  • Ruby has a clear and flexible way of writing code that helps create special languages for specific tasks.
  • You can change objects and code while the program is running, which is called metaprogramming.
  • It has lexical closures and iterators, which are ways to work with blocks of code.
  • You can easily create lists (arrays), key-value pairs (hashes), and patterns for text (regular expressions).
  • You can put code directly inside text strings.
  • You can set default values for function inputs.
  • Variables have different levels of access: global, class, instance, and local.
  • Ruby has garbage collection, which automatically cleans up unused memory.
  • It has Exception handling, which helps programs deal with errors gracefully.
  • You can change how operators (like `+` or `-`) work for your own objects.
  • It has built-in support for rational and complex numbers, and for very large numbers (arbitrary-precision arithmetic).
  • Ruby supports threads (for running multiple tasks at once) and fibers (for cooperative multitasking).
  • It supports Unicode for different languages and character encodings.
  • You can write parts of Ruby programs in C for better performance.
  • It comes with an Interactive Ruby Shell (IRB), which is a tool where you can type Ruby code and see the results right away.
  • RubyGems is a central system for managing Ruby packages and libraries.
  • Ruby works on all major computer systems.
  • It has a large standard library with tools for many common tasks, like working with web data (JSON, XML, HTTP) and graphics (Tk).
  • It includes Just-in-time compilation for faster performance.

How Ruby Code Looks

The way Ruby code is written is similar to Perl and Python. You use special keywords to define classes and methods. Code blocks can be defined with keywords or curly braces. Unlike Python, the spacing (indentation) of your code doesn't usually affect how it runs.

One key difference from Python is that Ruby keeps all its internal variables private. You can only access them through special methods called "accessor methods." This means you can't directly change the inside parts of an object from outside. Instead, you send a message to the object, and it responds. This helps keep code organized and prevents accidental changes.

How Ruby Works (Implementations)

Matz's Ruby Interpreter (MRI)

The original program that runs Ruby code is called Matz's Ruby Interpreter, or MRI. This interpreter is written in the C programming language and uses its own special virtual machine to run Ruby code.

Starting with Ruby 1.9, the official Ruby interpreter switched to a faster virtual machine called YARV ("Yet Another Ruby VM"). This is the main interpreter used in Ruby 2.x and newer versions.

Other Ways to Run Ruby

There are also other ways to run Ruby code, called "alternative implementations." Each one works a bit differently:

  • JRuby: This version lets Ruby run on the Java virtual machine. This means you can use Ruby code alongside Java programs.
  • TruffleRuby: Another Java-based implementation that uses a special framework to run Ruby code.
  • Rubinius: This uses a C++ virtual machine and can turn Ruby code into machine code while it's running, making it faster. Many of its core parts are written in Ruby itself.
  • mruby: This is a smaller version of Ruby designed to be put inside other C programs. It's useful for things like embedded systems.
  • Opal: This interpreter can turn Ruby code into JavaScript, so you can run Ruby programs directly in web browsers.

Many of these alternative Ruby versions are tested by seeing if they can run the Ruby on Rails framework. If they can, it means they are very complete and stable.

Where Ruby Can Run

Matz first created Ruby on a computer system called Sony NEWS-OS, but it later moved to other systems like SunOS and Linux. By 1999, Ruby was known to work on many different operating systems. Today, you can use modern Ruby versions on almost all major desktop, mobile, and server operating systems. Ruby is also supported by many cloud hosting services.

Tools like RVM and RBEnv help programmers install and manage different versions of Ruby and its libraries on one computer.

Ruby Libraries and Tools

RubyGems is Ruby's official package manager. A Ruby package is called a "gem." You can install gems using simple commands. Most gems are libraries, which are collections of code that help you do common tasks without writing everything from scratch. There are over 100,000 Ruby gems available on RubyGems.org.

Many new and existing Ruby libraries are also stored on GitHub. This is a popular website where developers can share and work together on code projects.

See also

Kids robot.svg In Spanish: Ruby para niños

  • Comparison of programming languages
  • Metasploit
  • Why's (poignant) Guide to Ruby
  • Crystal (programming language)
  • Ruby on Rails
kids search engine
Ruby (programming language) Facts for Kids. Kiddle Encyclopedia.