citizen428.blog()

Try to learn something about everything

Rubinius Has a New Fan

Being kinda sick I decided to use the weekend for emptying out my Instapaper account a little. Doing so I finally read Rubinius wants to help YOU make Ruby better on the Engine Yard blog. This reminded me that it’s been over a year since I last looked at Rubinius, so I used the excellent RVM to get the latest version and started my experiments. Basically everything I threw at it just worked, except for some of my scripts using 1.9’s new lambda syntax. Speedwise it seems to be more in the MRI 1.8.7 than the 1.9.2 range, but that’s fair enough. Getting adventurous I decided to try how Rubinius would handle one of my all-time favorite Ruby annoyances, the inability to override to_s in subclasses of String (don’t ask, but this once cost me almost an entire afternoon).

Example:

1
2
3
4
5
6
7
class SubclassedString < String
  def to_s
    "overriden"
  end
end

puts SubclassedString.new("original")

In MRI 1.8.7, MRI 1.9.2, JRuby HEAD and MacRuby 0.6 this will output “original”, which I believe to have tracked down to rb_obj_as_string in string.c in the MRI source (no idea about the other implementations). To my great surprise Rubinius 1.0.1 actually output “overriden”, which instantly won it a new fan. :-)

Comments