Ruby and Rails Updated
Written by Kay Ewbank   
Friday, 09 January 2015

Ruby 2.2.0 has been released, as has Rails 4.2 The improvements to Rails include a new Active Job framework, which has enabled support for sending asynchronous mails, faster queries, a web console, and better handling of foreign keys.  

The announcement about Rails 4.2  describes it as:

“full of great toys, useful gizmos, and polished edges, courtesy of a fantastic community of merry elves who've been coding away with jolly glee for months” 

This was written just before Christmas, so the cheerfulness is understandable. The blog post also says that this is probably the most well-tested new major release of Rails in a long time.

The Active Job framework is an adapter layer on top of queuing systems like Resque, Delayed Job, Sidekiq, and more. You can write your jobs to Active Job, and they'll run on all these queues with no changes.

The presence of an always-configured queue means it’s now possible to send Action Mailer emails asynchronously, so the developers have added a #deliver_later method that lets you add your email to be sent as a job to a queue, so you don't bog down the controller or model.

A new GlobalID library makes it easy to pass Active Record objects to jobs by serializing them in a generic form. This means you no longer have to manually pack and unpack your Active Records by passing ids. Just give the job the straight AR object, and it'll serialize it using GlobalID, and deserialize it at run time.

The faster queries come from an improvement project called Adequate Record for Active Record that makes many common queries run twice as fast as in previous version.

The web console is a development console that can be used to inspect the state of affairs on all exception pages, including the ability to jump between the different points in the backtrace.

Foreign key support is another area that has been improved; it has been problematic in earlier versions, but you can now use foreign keys without problem, according to the developers. The migration DSL gets add_foreign_key and remove_foreign_key and the standard schema.rb dumper will support maintaining these declarations. The only limitation is that it currently only works with the MySQL and PostgreSQL adapters.

Work is now underway on Rails 5.0, and this will target Ruby 2.2+ exclusively. The current release target for Rails 5.0 is Fall of 2015. The fact that Rails 5 will expect Ruby 2.2+ increases the important of the release of Ruby 2.2.0.

 

ruby

 

In practical terms, one of the most useful improvements to the new version of Ruby is the fact is Garbage Collector is now able to collect Symbol type objects, so reducing the amount of memory used by Symbols – until this version, the garbage collector was unable to collect symbols. Rails 5.0 will require Symbol GC, one of the main reasons why it will support only Ruby 2.2 or later.

The incremental GC also means a reduced pause time, and this is another area that Rails 5 is likely to take advantage of. Another feature related to memory management is an additional option for configure.in to use jemalloc Feature #9113 (libc's malloc is a problem, it fragments badly meaning forks share less memory and is slow compared to tcmalloc or jemalloc.). This feature is still experimental and currently disabled by default, but once the developers are happy with it, this feature will be enabled by default.

Experimental support for using vfork(2) with system() and spawn() have also been added. This could potentially result in much improved performance when a large process executes external commands many times, but the developers are still experimenting.

Other improvements have updated the bundled libraries, Psych 2.0.8, Rake 10.4.2, RDoc 4.2.0, and RubyGems 2.4.5.

More Information

Rails 4.2

Ruby 2.2.0 Released

Download Ruby 

Related Articles

Ruby 2.1 With Better Garbage Collection

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, FacebookGoogle+ or Linkedin,  or sign up for our weekly newsletter.

Banner


Is PHP in Trouble?
10/04/2024

The April 2024 headline for the TIOBE Index, which ranks programming languages in terms of their popularity, reads, "Is PHP losing its mojo" asking this question because this month PHP has dropped out [ ... ]



Microsoft Introduces .NET Smart Components
01/04/2024

Microsoft has provided a set of .NET Smart Components, described as a set of genuinely useful AI-powered UI components that you can quickly and easily add to .NET apps. The components are prebuilt end [ ... ]


More News

 

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Friday, 09 January 2015 )