Ruby VM Roundup: Ruby 1.9.2 Preview 1, Ruby Versions Site
The next version of Ruby is due later this year, and now its first preview version, 1.9.2 Preview 1, is available. A detailed list of changes is available, the release notes point out these API changes:
- Socket API was more objectified.
- Time was reimplemented and enhanced. Now Time has no max/min value, no year 2038 problem.
- New Random class for random number sequence.
- Good news for merb users: Method#parameters.
The last item on this list, new method
Method#parameters, is necessary for Merb's action arguments feature, which needs to know the number and names of a method's formal arguments. On Ruby 1.8.x, ParseTree was used to implement this functionality, but as ParseTree has been EOL'ed and is not available on Ruby 1.9.x, action arguments weren't available on 1.9.x. Workarounds were created for JRuby and for 1.9.1 with the methodpara gem.
Method#parameters, getting the formal arguments of a method is easy. Simply get a handle of the method and call
parameters. For instance, the arguments of this method
def hello(a,b,x=42, *args)
will be represented by this:
[[:req, :a], [:req, :b], [:opt, :x], [:rest, :args]]
A quick look through the Ruby Trunk ChangeLog (Caution: large file), shows a recent improvement by Narihiro Nakamura. The 'Longlife GC patch' (link shows the diffs) changes the VM and GC to treat long lived objects differently from other objects. According to the changes, in the current incarnation, long lived objects seem to be method bodies and inline cache entries. Remembered sets are used to track changes in the long lived space.
There are more plans for features to add to 1.9.2; it remains to be seen which make it into the final version.
Writing a compatible Ruby library was certainly easier half a decade ago when there was one mainstream Ruby version. Now libraries should be compatible with Ruby 1.9.x, as well as the host of alternative Ruby implementations.
David A. Black announced the Ruby versions site, http://ruby-versions.net/:
I've set up a site where you can ssh in and have access to a bunch of historical and modern Ruby versions and implementations, including Ruby 1.0 through 1.9.2 snapshot, Rubinius, JRuby, and Ruby Enterprise Edition.
Another way to check code across Ruby versions is MultiRuby, which will download Ruby versions and run code on all versions.
Tiago Romero Garcia Mar 01, 2015
How Can We Use Our Creative Power and Technological Opportunity to Address the Challenges of the 21st Century?
Gyorgyi Galik Feb 26, 2015