What Is Ruby 3?

Alicia Weenum
3 min readApr 18, 2023

Recently, my company upgraded to Ruby 3. Although the most recent version is 3.2.2.

I thought to do some research (mainly Ruby documentation) on the significance of Ruby 3. All versions coming after Ruby 3(3.0.6, 3.1.4, 3.2.2) are security fixes. So not too much excitement.

To start, what is Ruby?

Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993 and is now developed as Open Source. It runs on multiple platforms and is used all over the world especially for web development.

Ruby 3 Significance

First major point is that Ruby 3 will be 3 times faster*. Emphasis on the asterisk. It’s 3 times faster than Ruby 2 and also depends on your environment and benchmark.

  • Improvements on MJIT. Google more information on what this means and there will be further improvements in Ruby 3.1 regarding this.

2nd major significance is Concurrency/Parallel. As Matz said, “It’s multi-core age today. Concurrency is very important. With Ractor, along with Async Fiber, Ruby will be a concurrent language.”

  • Ractor is currently experimental. It’s an Actor-modal like concurrent(happening at the same time) abstraction designed to provide a parallel execution function without thread-safety concerns. Ex. Ractor.new
(Tak (function) — Wikipedia)

When diving into the documentation, you’ll notice that it’s a sending and receiving communication within the code. When comparing how quicky this ran, you can see that the parallel version is 3.87 faster than the sequential version.

Fiber Scheduler

Hopefully this sounds straight forward but here are supported classes/methods:

Fiber scheduler will support using async to provides the event look. This can make the hooks to make Net::HTTP non-blocking without having to use special gems.

RBS

I’m including this in the article as well because I’ve heard it brought many times, so assuming it’s important.

  • The goal of RBS is to support commonly seen patterns in Ruby programs and it allows writing advanced types including union types, method overloading, and generics. It also supports duck typing with interface types.(README of rbs gem)

TypeProf

TypeProf reads plain (non-type-annotated) Ruby code, analyzes what methods are defined and how they are used, and generates a prototype of type signature in RBS format. You can run TypeProf by saving the input as “test.rb” and invoking the command “typeprof test.rb”. (this is also experimental)

My last favorite feature of Ruby 3 is that pasting long code in the IRB is 53 times faster as well as the measure command.

Lastly, some updated gems

  • RubyGems 3.2.3
  • Bundler 2.2.3
  • IRB 1.3.0
  • Reline 0.2.0
  • Psych 3.3.0
  • JSON 2.5.1
  • BigDecimal 3.0.0
  • CSV 3.1.9
  • Date 3.1.0
  • Digest 3.0.0
  • StringIO 3.0.0

I hope this article goes over Ruby 3 briefly and I encourage to look at documentation to spark your curiousity.

Best, Alicia

#ruby3 #rubyonrails #javascript #softwaredeveloper #rubydocumentation

Any questions, feel free to reach out.

weenum.alicia@gmail.com

--

--