Ruby History Syntax References
Home Search



Ruby - Langpedia

Ruby

Website:

www.ruby-lang.org

Designed by: Yukihiro Matsumoto

Developer: Yukihiro Matsumoto and open source contributors

First appeared: 1995, 31 years ago

Implementation language: C

License: Ruby License

OS: Linux, macOS, freeBSD, other Unix-like systems, Windows

Filename extensions: .rb, .ru

Ruby

Ruby is an interpreted, high-level, dynamically-typed, general-purpose programming language designed to be productive and simple. In Ruby, everything is an object. It's interpreter uses just-in-time compilation and garbage collection.

History

Early concept

Ruby was conceived in 1993 by Yukihiro Matsumoto. He wanted the design of it to resemble a simple Lisp language at its core, with an object system like Smalltalk, blocks inspired by higher-order functions, and a practical utility like Perl.

Early releases

The first public release of Ruby was announced on Japanese newsgroups on 21 December 1995. After that, three more versions of Ruby were released in just two days. These versions included features like object-oriented design, classes with inheritance, mixins, iterators, closures, exception handling, and garbage collection.

In 1997, Matsumoto was hired by netlab.jp to work on Ruby as a full-time developer.

In 1999, the first English-speaking mailing list about Ruby began.

By 2000, Ruby was more popular than Python in Japan. In September 2000, the first English language book about Ruby was printed.

Ruby 1.8 and 1.9

Ruby 1.8 added features such as the allocate method, allowing creating object instances without invoking contructors and to_str method, which allows "duck typing" which allows objects to be implicitly cast to strings. It was stable for a long time, then deprecated in June 2013.

Around 2005, interest in Ruby surged due to Ruby on Rails, a popular web framework written in Ruby.

On 31 October 2011, when releasing Ruby 1.9.3, Ruby switched from being dual-licensed under the Ruby License and the GPL to being dual-licensed under the Ruby License and the two-clause BSD License.

Ruby 2

Ruby 2.0 was designed to be fully backward-compatible with Ruby 1.9.3. It introduced keyword arguments, lazy enumerators, a new regex engine, symbol list syntax, core class updates, among others.

Ruby 2.2.0 included performance improvements, bugfixes, and library updates. Ruby 2.2.0 also introduced an incremental garbage collector.

Ruby 2.3.0 included many performance improvements, updates, and bugfixes including changes to Proc#call, Socket and IO use of exception keywords, Thread#name handling, default passive Net::FTP connections, and Rake being removed from stdlib.

Ruby 2.4.0 included performance improvements to hash tables, Array#max, Array#min, and instance variable access.

Ruby 2.5.0 included rescue and ensure statements automatically use a surrounding do-end block, method-chaining, support for branch coverage and method coverage measurement, and easier Hash transformations.

Ruby 2.6.0 added an experimental just-in-time compiler.

Ruby 2.7.0 included pattern matching, REPL improvements, a compaction GC, and seperation of positional and keyword arguments.

Ruby 3

Ruby 3.0.0 was released on Christmas Day in 2020. It was known as Ruby 3x3, which means programs would run 3 times faster on Ruby 3 than Ruby 2. To achieve this, Ruby 3 added MJIT, a just-in-time compiler to make programs faster. It also greatly improved concurrency.

Ruby 3.1 was released on 25 December 2021, and added YJIT, a new just-in-time compiler developed by Shopify, and added a new debugger.

Ruby 3.2 was released on 25 December 2022, and added support for being run in WebAssembly, and improved regular expressions.

Ruby 3.3 was released on 25 December 2023, and added things like the Prism parser for portable and maintainable parsing, the pure-Ruby JIT compiler RJIT, and major performance boosts to YJIT.

Ruby 3.4 was released 25 December 2024, and added it block parameter reference, made Prism the default parser, improved YJIT, and added a modular garbage collector.

Ruby 4

Ruby 4 was released 25 December 2025, and added ZJIT, a JIT made in Rust, and "Ruby Box", a feature to provide seperation about definitions. The version number was bumped to 4 to celebrate Ruby's 30 birthday.

Syntax

The syntax of Ruby is close to Perl and Python.

Strings

s = "a string"
s = %Q{a string}
s = %{a string}
s = %/a string/
s = <<-BLOCK
a string
BLOCK

pie = 3.1415926535
"pi is #{pie}"

Collections

Arrays

a = [3, 'hi', 14.5, 1, 2, [6, 15]]
a[2]
a.[](2)
a.reverse
a.flatten.rotate

Hashes

hash = Hash.new
hash = { water: 'wet', fire: 'hot' }
hash.delete :water
hash.delete_if {|key,value| value == 'hot'}

Control structures

If statements:

if rand(100).even?
    puts "even"
else
    puts "odd"
end

Classes

class Person
  attr_reader :name, :age
  def initialize(name, age)
    @name, @age = name, age
  end
  def <=>(person) # the comparison operator for sorting
    @age <=> person.age
  end
  def to_s
    "#{@name} (#{@age})"
  end
end

group = [
  Person.new("Bob", 33),
  Person.new("Chris", 16),
  Person.new("Ash", 23)
]

puts group.sort.reverse

Exceptions

raise
raise "Error"
raise ArgumentError, "Illegal arguments"
raise ArgumentError.new("Illegal arguments")

References

En Wikipedia Org. (2026). Ruby (Programming Language). https://en.wikipedia.org/wiki/Ruby_(programming_language). Retrieved August 7, 2026.



All Langpedia content is licensed under the Creative Commons Attribution-ShareAlike 4.0 License.