Apr 23, 2021

about 3 min read

Ruby 3x3 - Is it actually three times faster?

Like most people, we have come to Ruby via Rails. For Ruby-lovers, Ruby 3x3 is an eye-catching gem. We have been using Ruby 2 since 2015, almost seven years without any updates. This time, Matz claimed, "Ruby3 will be three times faster than Ruby2". The excitement for this update also comes from concurrency and static analysis.



How Matz talks about his creation - Ruby3


In an interview with Jonan Schefler, Matz has revealed some trivia that ease the public curiosity about Ruby 3


The inventor' reason behind Ruby's speed

Matz said while creating Ruby, he focused on productivity and the joy of programming, thus making Ruby relatively slow. Later on, he and the team had to try many things to make Ruby faster. For example, the engine for Ruby 1.8 written by Matz was so slow. Luckily Koichi replaced the virtual machine, and it runs many times more quickly.


Why the name "Ruby 3x3"

Although they are an open-source language and not a business, Matz and the team tried hard to make Ruby better. Therefore he named it Ruby 3x3, which signifies a goal that it should be three times faster. He mentioned Javascript using JIT technique, which is not yet applied to Ruby 2. He aimed to leverage it and other tactics to improve the speed.


Features and major updates

About this significant and dazzling update, we have three main focus to discuss: performance, concurrency, and static analysis

Ruby 3 performance


"No language is fast enough." - Matz. 

Although the goal was to make Ruby 3 three times faster, they did not aim to make Ruby the fastest language out there. As Ruby language's performance gets boosted, applications are also faster and more scalable.


CPU optimization: The JIT(Just In Time) compiler was optimized from its previous versions. MJIT appeared first in Ruby 2.6. Ruby 3 MJIT today offers better security and significantly enhance web app's performance


Memory optimization: Fully automatic garbage compaction and object grouping allows for better memory usage.


Parallelism and Concurrency in Ruby 3

"I regret adding Threads." - Matz

Matz thinks Threads in Ruby is not at the right abstraction level for developers. This is improved in Ruby 3 as it is ideal for making applications with a focus on concurrency.

Fibers and Fiber scheduler: consider one of the cores of Ruby 3, Fibers replaces Threads, takes up less memory space. Code segments can be paused and then resume giving the programmer more control in I/O handling

Ractors (Guilds): VM lock (GVL) no longers hindrances parallelism with the help of a concurrent abstraction that is Actor-Model like - Ractors.


Static Analysis

"I hate tests because they aren't DRY." - Matz

Tests can result in code duplication, while it is very much helpful in checking the app. Therefore, static analysis is introduced. With inline type annotations that aren't dry, using .rbs file instead of .rb, static analysis is better than tests.


With so many new features and improvements in performance, concurrency, and static analysis, Ruby 3 is more satisfying to developers. The future of Ruby 3 is bright. This is good news in the new year 2021 for Ruby-lovers.  


If you want to upgrade your application to Ruby 3, contact Golden Owl - we offer up-to-date technology solutions that are cutting-edge.


Our latest posts

See more

April 23, 2021

about 4 min read

7 business benefits of custom website design

April 23, 2021

about 3 min read

Ruby 3x3 - Is it actually three times faster?

June 20, 2023

about 5 min read

5 Benefits of Automated Testing: A Complete Guide

Other Services