A Look at Rails 5
From the start, Rails was praised for being the easiest way to get Ruby on the web. It was the easiest option, and the best. Since then, many other options have arrived, but Rails is still the industry leading framework for Ruby developers.
As is tradition, this April at RailsConf 2015 in Atlanta, the creator of Rails, David Heinemeier Hansson (aka DHH) took the stage to announce what was new in Rails and to mark the release of Rails 5. This fits with the schedule of a major release every two years. And of course, folks were excited to get in early and see what our BDFL had to say about the future of Rails.
Here’s a look at some of the highlights.
TurboLinks 3
There were groans in the audience when DHH announced, again, his love for TurboLinks and their inclusion in Rails 5.
TurboLinks are a method for making your application feel a bit faster by using JavaScript to replace portions of content instead of reloading an entire page. But TurboLinks can also make an application a little heavy on client-side JavaScript, which can sometimes mean unresponsiveness or slowdowns. In addition, some devs struggle to get the performance boosts promised by TurboLinks.
Turbolinks have been part of Rails since version 4, but version 5 is looking to take advantage of the more advanced TurboLinks 3. This streamlines the process and makes use of Rack middleware and HTML5 custom data attributes.
If you are familiar with the functionality of TurboLinks in your application, do not fret! Things are not changing significantly. TurboLinks 3 will be an evolutionary step towards better speed and better rendering.
Action Cable
The biggest news at RailsConf was the introduction of Action Cable. Action Cable is a feature used to extend Rails via WebSockets to add real-time message passing functionality.
While WebSockets are not a new concept, the integration with Rails has been fraught with difficulty. So this is a welcome addition for people who don’t want to mess with workarounds.
Action Cable is still in the early stages of development and there is likely to be more information on it before we see it’s release as part of Rails 5. But considering the amount of projects requiring real-time interaction (be it for chat, feeds, and so on) Action Cable looks to be an overall boon to Rails developers.
CoffeeScript
DHH has reaffirmed his love for CoffeeScript. Baked into Rails in version 3, CoffeeScript was made the default JavaScript option when using Rails. Some developers believed this was went too far. The concern was that any default effectively means a “must use” for Rails developers, especially devs that work on a large number of projects.
Two versions later, CoffeeScript is still the default and it would seem the decision has gained a wider acceptance. For some people, that’s because the “must use” fear didn’t pan out, and for others, it’s because they tried CoffeeScript and they liked it.
One thing we can be sure of is: CoffeeScript is the default JavaScript flavour in Rails, and this won’t be going away anytime soon.
Ruby Version Support
Rails 5 will only support Ruby versions 2.2.1 and higher. As Ruby progresses as a language, backwards compatibility needs to be sacrificed for new features. Older versions can’t be supported indefinitely. Rails is no different. Though, Rails is making the sensible decision of only supporting the most widely used version, starting with 2.2.1 and including all stable releases after.
Because of this, it is unlikely that someone using Ruby 1.9.3 would want to move to Rails 5. It’s possible they will remain on a lower version until some other external factor forces an upgrade and a refactoring of the code. For some dev shops, that may not happen for years, which is perfectly understandable.
For some, this is a barrier to Rails 5. For others, it is an opportunity upgrade and improve an application that may be in need of some love.
Conclusion
Rails 5 is almost upon us.
It looks as if we have a lot to look forward to: Turbolinks upgrade for better rendering, Action Cable for better real-time message handling, more CoffeeScript (if you’re into that), and moving forward with the Ruby ecosystem.
If you can upgrade, upgrading is your best option. Though, depending on how much time you have, it may be a good idea to let the early adopters kick the tires.
P.S. What are your thoughts on Rails 5? Were you there for the announcement at RailsConf? Leave us a comment!
Share your thoughts with @engineyard on Twitter
OR
Talk about it on reddit