The Ruby Standard Library To Be Converted to Gems for Ruby 2.0?

By Peter Cooper

The Ruby standard library (a.k.a. stdlib) is a collection of Ruby libraries that, at one time or another, have been considered useful enough to include with the MRI Ruby implementation by standard. Due to the popularity of these libraries, other Ruby implementations have then tended to re-implement or include the standard library too.

As part of the march toward Ruby 2.0, the state of Ruby's 'standard library' has come up for discussion. A popular line of thinking (and IMHO, very likely to actually happen) is that the standard library should be 'gemified' for Ruby 2.0.

Why Gemify the Standard Library?

The standard library approach has a significant flaw. Due to being a large and critical piece of software, MRI's release cycle is slow, yet some libraries require faster updates, perhaps for security or API updates. It would be better, therefore, to have the standard libraries maintained and distributed separately while still being included 'by default' with Ruby implementations.

We have already seen this sort of approach with RubyGems itself. For example, RubyGems is (at the time of writing) at version 1.8.11, yet the barely 2 week old Ruby 1.9.3p0 comes with RubyGems 1.8.10. While RubyGems is not itself distributed as a gem, it demonstrates the value of having something included with Ruby and still updateable separately.

Aaron Patterson (of the MRI Ruby Core Team) Explains

In his talk at RubyKaigi, Aaron tenderlove Patterson spoke about working out which parts of Ruby are 'third party libraries' and how to extract them. After such extraction, Ruby core should be able to commit to or change anything within MRI, but also reference third party gems that are included and installed by default on new installations. Aaron noted that being able to 'iterate faster' was a significant benefit of this approach.

Aaron also explained that with less coupling between Ruby implementations and the libraries they depend upon, it could be possible in future to upgrade your Ruby interpreter while still maintaining existing versions of the libraries you depend upon. This could help you migrate more gradually or merely help you maintain existing compatibility.

Further Reading

The process of gemifying the Ruby standard library is explained on the Ruby implementation wiki with the proposal, implementation, and a list of to do items already laid out. A more extensive discussion (which you can join) is also taking place on the official MRI Ruby issue tracker.

This process is still in its early stages and there are likely to be opportunities to help maintain or even become the maintainer for certain standard libraries, if you want to get involved.