Below, you’ll find Wojciech Maciejak, our former senior Ruby and JavaScript developer, briefly reviewing recent major changes in the world of Ruby on Rails.
Ruby on Rails continue to evolve, with significant improvements in performance and scalability over the past few years. We’ve noticed in recent years a significant increase in the number of applications built with Ruby on Rails in “the API only” mode. Thanks to that, it is possible to create an API as an MVP quickly, and at the same time, build the frontend of the application in any JS framework.
What’s more, writing Single-Page Applications (SPA) is getting some traction, and it’s one of the strong trends right now. At Monterail, we’ve already built some SPAs with Laravel Vue Stack, so in 2024, it’s time for Ruby.
Back to the roots - Hotwire in 2023
In 2023, we could observe going back to the roots of the Ruby on Rails world with Hotwire. Along with its appearance, we’re finally able to build efficient and modern Web applications within one application in a very fast way and without poor development experience. The funny thing is, we’ve been using similar techniques but never in such an organized, cohesive way.
Hotwire has gained traction as an alternative to traditional JavaScript-heavy frontend frameworks for Rails applications, particularly with the release of Turbo 8. Many developers find it a fast and productive option, especially for smaller teams and solo developers.
The Turbo 8 update brought significant improvements, including enhanced performance through optimizations for faster page loads and smoother transitions. Alongside Turbo 8, the Hotwire ecosystem has expanded with new tools and extensions. A notable addition is the Hotwire Browser Extension, which aids in developing and debugging Hotwire applications.
Stimulus, a core component of Hotwire, has also seen substantial advancements. Developers can now implement smooth concurrent updates using Stimulus and Turbo Stream broadcasts, enhancing real-time functionality in applications. Using custom Turbo Stream actions has expanded the capabilities of Stimulus controllers, offering more flexibility in application design.
Hotwire's integration with Ruby on Rails has strengthened considerably. Full support for Rails 7.2 ensures seamless integration with the latest features, keeping Hotwire at the forefront of Rails development.
Performance boost!
Ruby and Ruby on Rails have been facing performance issues for years now, but real change has been on the horizon, too. I observe a strong focus on dealing with this aspect and improving the framework and language itself.
The Ruby 3.0 version turned out to be three times faster than Ruby 2.0 and predictions made by Jakuhiro Matzuomoto. Now, version 3.1 takes another step toward better performance. One of the steps was implementing the so-called “Fiber Scheduler” which allows for asynchronous work of Ruby without any side effects or tedious developer’s work.
It means one thing - one of the strongest arguments against Ruby is slowly losing its relevance! Ruby is getting more and more performant, no doubts about that!
Ruby takes a closer look at well-known problems and modifies the way the framework works and makes it towards asynchrony, too. At the beginning of 2022, a new version of the PG gem was released that enables making asynchronous requests to the database. It only proves the general development direction of the Ruby community.
Encrypt everything with Rails
In Rails 7, we finally see one great feature which was long-awaited in Rails. Our databases were never encrypted by default. In general, it does not mean that it was unsecured, but if we can do it, we just should encrypt even simple data in the database.
Now you don’t have to add any gems or additional implementations, you can just use simple command because Rails support encryption out of the box. It’s a really important feature of Rails 7!
The introduction of Active Record Encryption in Ruby on Rails 7 has significantly elevated the focus on security within the framework. This built-in feature has transformed database encryption from a complex, optional add-on to a core, easily implementable functionality. By allowing developers to encrypt sensitive data with just a single line of code in their models, Rails has made robust security practices more accessible and widespread. The automatic encryption process between the application and the database provides an additional layer of protection, safeguarding data even in the event of unauthorized database access.
Parallel Execution in Ruby
Not all changes in Ruby on Rails are thought out in advance. Some of them remind me of an experiment that shows that RoR is not afraid of trying new things. One such feature is Ractor - a Ruby Actor Model which will offer parallel computation capabilities to Ruby apps.
It works like service workers in JavaScript, allowing for the implementation of proper threading between processes, ensuring safety due to fewer deadlocks and livelocks. Their communication is based on message passing, substantially different from conceptual threads.