James Gray
1/8/2008 7:27:00 PM
On Jan 8, 2008, at 1:05 PM, Jeff M. wrote:
> Hello, peeps. I'm dipping my feet into Ruby waters (from Smalltalk).
Hello and welcome to Ruby.
> I see that Ruby 1.9 is out and Leopard shipped with 1.8.6. I also
> heard that 1.9 would introduce a new VM that would be significantly
> faster than 1.8. Is that the case?
It is faster in many cases, slightly slower in a few, and similar
speed in some others.
> If so, is there a standard way of getting 1.9 on OS X or am I kinda
> stuck waiting for Apple to "do their thing"?
The important thing to know is that Ruby 1.9 is currently a
"development release." It has known problems. The core team is
sorting those out, but it's going to take a little time to firm up.
Thus, as a new user, I recommend you stick with 1.8.6 for now to avoid
running into any of these issues.
To answer your question though: you do not have to wait for Apple to
upgrade Ruby for you, no. Many of us keep our own build (in /usr/
local) and update it as we desire.
> However, if I ever wanted to distribute my code or
> a program, is there a proper way of distributing everything needed
> with it?
Short answer: yes.
Longer answer: how you handle this depends on how you distribute your
software. Gems can have dependencies, for example. There are also
some all-in-one-executable solutions.
> Perhaps I've missed this in documentation, but am I able to extend a
> class without subclassing? Something akin to "loose methods" in
> Smalltalk?
Sure. Ruby has open classes, so we can add methods to them at any time:
$ irb
>> class String
>> def to_rot13
>> tr 'a-zA-Z', 'n-za-mN-ZA-M'
>> end
>> end
=> nil
>> "James Edward Gray II".to_rot13
=> "Wnzrf Rqjneq Tenl VV"
Hope that helps.
James Edward Gray II