Ruby on Rails takes on Node.js with WebSocket support, API mode

The first beta for the 5.0 edition of the popular Web framework for Ruby is out, with WebSockets support as a major feature -- and with Ruby 2.2.2 as a requirement

Ruby on Rails takes on Node.js with WebSocket support, API mode
Credit: flickr/Luis Villa del Campo

Ruby on Rails has thrown open the doors to the first public beta edition of Version 5.0 almost 10 years to the day from when Version 1.0 debuted, and some 11 years and change after its very first release took flight. With the new update, Rails attempts to keep its existing user base and woo fresh adherents with a slew of new features.

The biggest change: Rails 5 runs exclusively on Ruby 2.2.2 and above. Rails' developers wanted to take advantage of the features and performance enhancements in that edition of Ruby, and they made this clear from the beginning of Rails 5's development.

Rails 5 also features ActionCable, which integrates WebSockets with Rails apps. WebSockets is a standardized way for HTML5 applications to communicate in real time without the overhead commonly associated with an HTTP connection. But it requires a fair amount of work to get running, and it typically requires a specialized component of some kind in a Web application.

Node.js has native support for WebSockets and could in theory be deployed side-by-side with other items -- such as Rails -- to satisfy that need. ActionCable, though, allows WebSocket services to be written in Ruby alongside one's own Rails app, so both conventional and WebSocket traffic can be handled by the same Ruby code.

Also new is API mode, which creates a Rails application with a stripped-down feature set. Rails apps created in API mode serve JSON, not HTML, and the components used to render HTML aren't included by default in the app.

Many of the other changes ease day-to-day use, such as moving all command-line commands to bin/rails for simplicity's sake, or are about upgrades to newer versions of other components, such as version 4 of Sprockets, the Ruby library used by Rails to package Web assets like JavaScript and CSS. The upgrade instructions for Ruby on Rails already offer details for transitioning from 4.2 to 5.0, although developers won't have to make a large number of changes to their apps.

Rails benefits from having a lot of applications already built on top of it, and from remaining one of the top go-to frameworks for creating Web apps quickly and without sacrificing coherence and cleanliness for convenience. Indeed.com's job tracking reports for Ruby and Ruby on Rails show interest rebounding significantly over the past year.

But the rise of Node.js, despite its relative lack of maturity, has displaced a lot of Rails mind share in the Web services space. Node.js's performance routinely outstrips Ruby's, and the Npm library of Node packages continues to expand (218,000 on npmjs).

The main competition for Rails 5 in the short term will not come from Node but from earlier versions of Rails, as is generally the case with any new version of a framework.

From CIO: 8 Free Online Courses to Grow Your Tech Skills
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.