Ruby 2.1.0 preview2 is out, and the ruby-core team is planning to release 2.1.0 on Christmas Day, 2013.

To stay on top of the changes, I did some research on the release notes provided on the ruby-lang site (see below for links). The first level of bullets is verbatim from the release notes, the second level are my notes. I hope they help clarify some of the changes in the pipeline!


  • VM (method cache)
    • klasscache, see ko1 pg 19
    • Same algorithm as JRuby and Rubinius
    • Not just a global method cache anymore
  • RGenGC (See ko1’s RubyKaigi presentation and EuRuKo presentation)
    • Restricted generational garbage collector
    • Faster than “mark and sweep” (M&S)
    • “True” generational GC would have caused compat problems
    • Complications with the C extension API
  • Refinements
  • Syntax
    • Required keyword arguments now have a syntax
    • def foo(bar: 2) defaults bar to 2 if not present, def foo(bar:) requires bar
    • Pre-2.1.0, you could do def foo(bar: bar) to a similar effet
  • Decimal Literal
    • Pre-2.1.0: Rational(1, 2), 2.1.0 and later: 1/2r
    • Lets you represent fractions without the normal pain associated with IEEE floating point
  • Frozen String Literal
    • "bar"f, frozen string… looks funky
    • This syntax was dropped, see preview2
  • def’s return value
    • name symbol, now you can do private def foo
    • seems like it might interfere with Rubinus, which returned a method object
  • Bignum
  • 128bit
  • GMP
    • If available, 128bit math is used for large numbers. Sounds like it’s provided by GMP, the GNU Multiple Precision library
  • String#scrub
    • Cleans invalid byte sequences
  • Socket.getifaddrs
    • Accessing Network Interfaces (“get i_nter_f_ace _addr_esse_s“)
    • Methods like name (e.g. en0) and ip_address (either IPv4 or IPv6)
  • new RubyGems


  • fix Heap Overflow in Floating Point Parsing (CVE-2013-4164)
  • f suffix of String Literal is removed #9042
  • “literal”.freeze is now optimized #9042
    • Backwards compatible syntax! It gets the same optimization of the f suffix
    • Freezing Strings can give us some easy optimizations
  • fix memory consuming issue on RGenGC (r43532 and r43755)
  • add Exception#cause #8257
  • update libraries like json, nkf, rake, RubyGems, and RDoc.

My experiences so far

Since the code in Maid is fairly straightforward, I’ve been trying to keep it up to date with new Ruby versions. It was a pretty simple update, but I ran into some issues.

While the above bullet points are only the “notable” changes, some others are detailed in the NEWS file. However, I ran into an API change I didn’t see documented anywhere.

It started by running into a strange ArgumentError when using FakeFS to list the contents of a directory:

ArgumentError: wrong number of arguments (2 for 1)

I tracked it down to Dir.entries adding an optional second argument between Ruby 2.0.0 and 2.1.0 (details). In Ruby 2.1.0, Find.find was calling FakeFS with the optional 2nd argument, which it didn’t know how to handle. I made a simple pull request on FakeFS to fix the issue. It was a little difficult to track down, but not too bad. For what it’s woth, I also ran into some trouble using FileUtils.touch with an :mtime option, but I might have been using it inappropriately.

Otherwise, I got updated to 2.1.0, as you can see in the Travis CI build. :)


These are what I read when researching the above. I hope they can help point you to more information.

Update (2014-02-05): We have been running Ruby 2.1.0 in production for a few weeks, with very few issues. We had a random MySQL issue that took less than an afternoon to figure out. Overall, the upgrade was fairly painless!