How To Start Playing With Ruby 1.9 Right Now!

By Peter Cooper

Ruby 1.9 is almost upon us! With an expected release date around this Christmas, it won't be long until you can start to play with Ruby 1.9 and enjoy some of the much-hailed performance increases (not to mention features).

"But I want it now!" you say. Well, as an open source project with an active ruby-core community working on a public code repository, it's totally possible to get yourself a copy of Ruby 1.9 and begin playing with it today. You can't expect to run production code on it and you shouldn't expect any code to be rock solid, but with the release date such a short time away, you might find it feels "close enough" now for you to really get knee-deep in the new features, and you know how great it'll be to pull out some great new techniques later on when the rest of your co-workers are still upgrading..

I've just exported the latest version of Ruby 1.9 from the ruby-core trunk. If you have SVN and you're happy to do this too, follow the instructions given here, otherwise follow the instructions below to use my "no SVN required" technique:

Fire up your shell or terminal app. Download and un-tar: http://s3.amazonaws.com/rubyinside/ruby1.9-trunk-2007-11-27.tar.gz On some operating systems this is as simple as: wget http://s3.amazonaws.com/rubyinside/ruby1.9-trunk-2007-11-27.tar.gz

tar xzvf http://s3.amazonaws.com/rubyinside/ruby1.9-trunk-2007-11-27.tar.gz Then get installing.. cd ruby1.9-trunk

autoconf

./configure --prefix=/usr/local/ruby1.9

make

sudo make install

By now you should have Ruby 1.9 installed in its own directory (so it won't mess up your existing Ruby 1.8 install). Don't worry if an error crops up during documentation generation (I get a "Bus Error") as the key items are already installed and ready to use like so:

/usr/local/ruby1.9/ruby -v /usr/local/ruby1.9/irb

Double check that you're running the right version when you're in IRB and try out a new feature:

iMac2007:ruby19 peter$ /usr/local/ruby1.9/bin/irb

irb(main):001:0> Time.now.to_s

=> "2007-11-27 20:15:44 +0000"

irb(main):002:0> Time.now.tuesday?

=> true

Enjoy! Give some of your usual Ruby apps a try if you like, run some performance tests, or check out this insanely detailed list of changes and new features in Ruby 1.9. Have a play, and if you find anything other readers might find interesting, leave a comment here at Ruby Inside!