Below, you’ll find Wojciech Maciejak, our former senior Ruby and JavaScript developer, briefly reviewing recent major changes in the world of Rails.
Ruby on Rails continues to evolve, with significant improvements in performance and scalability over the past few years. We’ve noticed a significant increase in the number of applications built with Ruby on Rails in “the API only” mode in recent years. Thanks to that, it is possible to create an API as an MVP quickly and build the front end 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 development 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 Rails developers find it a fast and productive option, especially for smaller teams and solo devs.
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.
Simply put, the argument against Rails development due to performance concerns is rapidly losing relevance!
Encrypt everything with Rails
In Rails 7, we finally see one great feature which was long-awaited. 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.
Historically, databases in Ruby on Rails development were not encrypted by default. While this did not necessarily mean they were insecure, there was always room for improvement. Now, Rails includes built-in encryption, eliminating the need for additional gems or third-party solutions.
With Active Record Encryption, developers can encrypt sensitive data with just one line of code, making security more accessible and standardized. This ensures that sensitive data remains protected, even in cases of unauthorized database access.
For businesses handling user-sensitive data, this feature solidifies Ruby on Rails development as a trusted choice for secure web applications.
Parallel Execution in Ruby
Not all changes in Ruby on Rails development 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.