Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

23 Useful Ruby 1.9 Links and Resources

By Peter Cooper / February 9, 2009

ruby-1-9-1.gifIt's approaching two weeks now since Ruby 1.9.1 was released, bringing with it not only a whole stack of extra performance and a new VM, but also a lot of compatibility issues. No pain, no gain!

Thankfully, the Ruby community in its typical way has got to blogging, writing scripts, and what not, resulting in a flurry of useful links and resources for those brave enough to test the Ruby 1.9.1 waters. So here come 23 useful Ruby 1.9.1 links and resources! If you have any others you wish to add, please leave a comment as people will be checking those out too.

Ruby 1.9.1 Specifically..

build_ruby19.sh - A quick shell / bash script that downloads Ruby 1.9.1 from ruby-lang.org then untars and installs it. It uses a "program suffix" of "19" so it shouldn't overwrite your existing Ruby 1.8 programs. Instead you'll end up with ruby19, gem19, irb19, and so forth. This strategy makes it a cakewalk to run two versions of Ruby at the same time. Want a script that installs both? Try this instead (it makes the 1.9 versions the "default" though). All somewhat based around these similar Web-based instructions by Ryan Grove.

Future proofing your Ruby code. Ruby 1.9.1 is coming. - Australian superhero Dr Nic Williams takes a look at using multiruby to run Ruby 1.9 and 1.8 on the same system. This is quite a different approach to just installing them separately with different suffixes and might suit your workflow better.. Ken Collins has also written MultiRuby The MacPorts Way which takes a slightly different approach.

Getting ready for Ruby 1.9.1 - The Phusion guys (behind the excellent Passenger / mod_rails) give some tips regarding running Rails apps on Ruby 1.9.1. They explain that you must move on up to Rails 2.3, that you'll need to patch a ton of gems, but that the latest build of Phusion Passenger will work happily with Ruby 1.9.1.

Ruby 1.9.1 - The Stuff It Gives Us - Justin Reagor presents an overview of 8 new features / differences (with code examples). For example, you can now overload operators like !, !=, and !~, hashes preserve their order, and newlines can go where no newline has gone before.

Is It Ruby 1.9 - A community site where you can track gem compatibility with Ruby 1.9 (Ruby 1.9.1 specifically, though) as well as make reports of your own. If you want to contribute to the community in any way right now, this is a good place to do it. Get those reports and fixes in!

Installing Ruby 1.9.1 & Rails from Source on Ubuntu Screencast - A 7 minute walkthrough of installing Ruby 1.9.1 and Rails from source on Ubuntu (rather than via apt-get) by Joon You. This should work on Debian as well.

Ruby 1.9.1 Release News - The official "NEWS" list from the 1.9.1 release. It doesn't go into details but presents a gigantic list that expresses what's new and what changed in Ruby 1.9.1 versus 1.8. Certainly worth a quick scan.

Ruby 1.9 Generally..

Migrating to Ruby 1.9 - Bruce Williams' presentation covering Ruby 1.9 at a high level. Lots of pithy code examples, M17N is covered, etc. A great resource if you get bored quickly as you can just flick through in a few minutes.

Working with Encodings in Ruby 1.9 - A very solid introduction to M17N (multilingualization) support in Ruby 1.9 with examples.

Changes in Ruby 1.9 - A classic guide to the changes in Ruby 1.9 by Mauricio Fernandez. Sadly it's not been updated since 2007 but it's such a gigantic list packed with excellent code examples that it should still be essential reading.

10 things to be aware of in moving to Ruby 1.9 - David A Black (of RubyCentral and Ruby for Rails fame) highlights 10 "gotchas" that could bite you in the ass when moving to Ruby 1.9. Includes String#each, block variables scope and semantics, the * operator, and more.

Fun with Ruby 1.9 Regular Expressions - Dave Thomas (of Pickaxe fame) presents a very compelling code example showing how regular expressions have grown up in Ruby 1.9. You can now write some pretty advanced parsers using the new features.

Getting Code Ready for Ruby 1.9 - James Edward Gray II wrote a year ago about some of the changes you'll need to take into account when moving from Ruby 1.8 to 1.9. Still good reading and the plentiful comments make it worth the trip.

Benchmarking Ruby - Evan DiBiase has just (as in, a few days ago) performed some benchmarks on JRuby 1.1.6 (and an early build of 1.2), MacRuby, Ruby 1.8.6, and Ruby 1.9.1. Benchmarks are always hard to get right, but he finds that while Ruby 1.9.1 is significantly faster than 1.8.6, JRuby is faster still. (I have found this to be true in my own work.. JRuby is on fire!)

The December 2008 Great Ruby Shootout - Antonio Cangiano's famous Ruby benchmarking shootout. It wasn't without flaws (what benchmarks are?) but it showed us that Ruby 1.9 is approximately double the speed of 1.8.

Pipelines Using Fibers in Ruby 1.9 - It's from all the way back in 2007 but Dave Thomas shows how to use Ruby 1.9's "fibers" feature to implement a pipeline of operations. Note that it leads on to a second part too.

Why you should use Ruby 1.9 with Prawn - Gregory Brown explains with Ruby 1.9 is so awesome for his Prawn PDF library. The tests run in half the time and Ruby 1.9's text encoding features make life a lot easier.

Arrow Lambdas, a Ruby 1.9 Vignette - A code-driven walkthrough of lambdas in Ruby 1.9 by Bruce Williams. This is the best casual walkthrough of the new lambda syntax(es) for 1.9 I've seen so far.

Ruby 1.9 can check your indentation - No, no, this isn't the start of a process leading to a Ruby/Python merger with Ruby 3.0 (though never say never).. it's just that Ruby 1.9 can now see if indentation is mismatched on things like if statements or method definitions and give you better warnings when you get things wrong. Another great post by Dave Thomas.

Comments

  1. Gregory Brown says:

    Peter, thanks for mentioning my article. Unfortunately I had to follow it up with an apology:

    http://blog.majesticseacreature.com/archives/2009.02/lies_and_statistics.html

    Just because Ruby 1.9 has a better Makefile isn't a cause for me to get so excited. That having been said, I think Prawn will still be faster on Ruby 1.9 generally, I just haven't had time to put together concrete tests.

  2. Antonio Cangiano says:

    Peter, the flaws you mention were fixed a long time ago.

  3. Peter Cooper says:

    I guess I should have kept an eye out. Almost every article that includes benchmarks nowadays seems to get a followup ;-) ! :)

  4. Ryan Tomayko says:

    Markus Prinz has a couple of useful 1.9 related articles:

    http://blog.nuclearsquid.com/writings/ruby-1-9-what-s-new-what-s-changed
    http://blog.nuclearsquid.com/writings/ruby-1-9-encodings

    The second article brought me up to speed on Ruby's encoding changes very quickly.

  5. Radar says:

    The guide on my site does not show how to use 2.2.2, what I'm patching there is actually rack (a requirement of 2.3/edge rails). I had issues with 2.2.2 (which unfortunately I didn't document), hence why I use edge.

  6. elliottcable says:

    The advantage of my approach (regarding the build script linked) is that you can *chose* which of the two versions is run when you run the non-prefixed commands - e.g. `irb` can be linked to `irb19` or `irb18`, depending on your needs. And you can change your decision later without re-building everything!

  7. khelll says:

    I suggest this nice post to install multiple ruby versions on ubuntu

    http://blog.michaelgreenly.com/2008/08/multiple-versions-of-ruby-on-ubuntu-2.html

Other Posts to Enjoy

Twitter Mentions