Ruby is Dead. Wait, Really?

For many observers, Ruby seems to be on the decline. But, for many Rubyists, the language is going to have a second spring. What are the reasons for this? Let’s find out!

Is Ruby Dead?

In recent years the popularity of Ruby dropped on various “popular programming languages” indexes like Tiobe or Pypl.

Rails, the most famous software piece of Ruby was a long-reigning king of web development but it lost steam recently as well. Especially the sudden and huge rise of node and the steady rise of Django undermined the status for Rails.

Another problem for the Ruby community was that the language got kind of infamous for being “too slow for web-scale”. (See my response to the scalability issue here) This reputation manifested especially after Twitter moved away from Rails and used Scala for their needs.

All of this led to the rumor that “Ruby is dead”. But, why do many Rubyists think that Ruby indeed has a glorious future?

The Glorious Future of Ruby

Ruby 3x3 and its Future

Matz, the creator of Ruby, tried to stop this development by giving the Ruby 3x3 goals out. And boy, did this revivify the optimism in the Ruby community! Many developers were looking forward to this release with great hope. And with the release of Christmas 2020, it was finally here!

Did it fulfill all its promises? — Well, kinda.

The performance was in certain benchmarks three times as fast as Ruby 2.0 but not for big Rails applications. But the investment in performance improvements didn’t stop with the release of Ruby 3, in fact, they are ever-increasing. As an example, recently Shopify, one of the biggest Ruby/Rails users, hired some Ruby developers to implement a JIT compiler in the CRuby implementation. With this, the performance should continue to become better and better. Also, in his last keynote at Euruko, Matz reinforced the focus on performance again when he said that Ruby 3.x will be 3 times faster than 3.0.

For big web applications, the CPU-bound performance isn’t the main problem, most of the time. The problem lies in the IO bound operations, and Ruby has made some huge improvements there! We now have an API for Fibers to build something like green threads.

With this, the Ruby interpreter is able to handle many requests concurrently and increase the throughput a lot. With the async gem, we already have a reference implementation for this, which might become part of the standard gems for Ruby. It still needs a little bit of time for other gem maintainers to use this new option but this will be a huge boost for the Ruby ecosystem in the end!

In my opinion, this will have the biggest impact of all the features that have been added to Ruby for the 3x3 goals.

Samuel Williams, the developer behind the async gemset recently tweeted some very impressive benchmarks demonstrating how scalable this approach is.

As another benefit from the Ruby 3x3 goal, the Ruby community now has some good options for better IDE tooling.

Stripe open-sourced Sorbet, a type checker for your Ruby programs. If Sorbet isn’t your thing then you can use Steep. This one works with separate files for types, something like TypeScript does at well.

Alternative High-Quality Gems

Another great development in the Ruby community is that we have some really high-quality alternatives for well-known gems.

  • Sequel: This gem is a long-standing alternative for Active Record. It has a plugin system that can load a lot of additional features. The performance of this gem is also better than ActiveRecord in most benchmarks. Something that stands out for this gem is that there are zero open issues at, nearly, any given point in time. The maintainer, Jeremy Evans, does an excellent job of keeping everything super clean!
  • Hanami: Hanami is another long-standing web framework that is in the transition phase right now. It already made some huge improvements and the plan for the future looks very promising to me (here is a presentation from a core developer).
  • Smaller very focused high quality libraries: One foundation for the Hanami web framework is the dry-rb gemset. These are specialized libraries that are a valuable addition to nearly all Ruby applications where any gem does one thing and does it well.

Continued Investment in Ruby

Another big beacon of hope for Ruby is the ongoing and ever-increasing investment in Ruby. As mentioned above Shopify is betting big on Ruby and has hired several Ruby/Rails core developers.

Some of them are working on a new and novel JIT technology called YJIT. The basic idea behind this JIT compiler is called Basic Block Versioning (BBV), something that one of the developers working on this, Maxime Chevalier-Boisvert, has described/worked on in her Ph.D. thesis. The big goal for this JIT is to be integrated with CRuby and gain a performance boost for Rails servers.

Another investment from Shopify and Oracle is the research on TruffleRuby, a high-performance Ruby implementation using the GraalVM technology. Right now TruffleRuby isn’t able to run Rails because of some C extensions that are not working. But for smaller scripts and programs that can run with this implementation the performance gains are huge.

The research for this implementation is also bearing fruit for CRuby as seen most recently in the Ruby Kaigi 2021 talk about Object Shapes.

Other big Ruby users that are investing in the platform include Stripe, which is developing Sorbet, GitHub, which has several Rails core developers on their payroll, as well as Heroku, Cookpad, and many more.

With this kind of corporate baking of a language, it is very unlikely that Ruby is going down anytime soon!

Final Thoughts

So, after looking at the current state of the Ruby ecosystem I personally think that there is a bright future for Ruby but one that we, as a community, have to continue to work for to get there. This work can be developing and maintaining the gems we rely on or are looking forward to use — especially using the improvements that recent Ruby development made available like the Fiber improvements.

Another area for improvement is the documentation for these gems. So, that others can start to use alternatives and have the best experience doing so possible. Also, let’s spread the word: Ruby is not dead but has a glorious future!