Whether people have noticed or not, Prawn has been developed on Ruby 1.9 from the ground up. But now that Ruby 1.9.1 has been officially released and marked stable by ruby-core, I want to give you a few reasons why you should use it with Prawn if you have the chance.
Though it may go without saying to those watching Prawn closely, as an end user, you may not know that issues with Ruby 1.9 are considered release-blocking defects to us. All contributions to Prawn must be fully compatible on Ruby 1.9, with no special casing. We run all the tests, and all the examples to make sure that things are working smoothly on 1.9. This means that we won’t wait until we hear complaints to fix 1.9 issues, but rather do the best we can to get them ironed out before anyone ever sees them.
Because we develop on 1.9 and then backport to 1.8, your Prawn code should run identically on both platforms, with two notable exceptions.
Here’s a quick a sample of how long it takes Prawn’s tests to run on both platforms:
And here’s a side by side timing of running the example suite:
Although you’re bound to run into individual differences, the speedup across the board tends to run between 2 and 3 times that what you’d expect on Ruby 1.8.6. Since you get this speed boost for ‘free’, it’s a compelling reason to try Prawn on 1.9.1 if you don’t have a reason not to.
On Ruby 1.8, we’re not able to track the encoding of your strings, so we require all of your text to be coded in UTF-8. On Ruby 1.9, you have some more options. Although our underlying operations depend on Unicode, if you’re running Ruby 1.9.1, you only need use strings that are encoded in a character set that can be converted to UTF-8. We handle this conversion for you. For an example, take a look at SJIS rendering on Ruby 1.9:
Ruby 1.9’s M17N support is a big and complex topic, which I definitely don’t want to get into it here. You’ll eventually be able to find some good details in my book , and you might also want to keep an eye on James Gray’s blog , which has covered 1.8 pretty comprehensively as well as provided some general encoding background. Until then, this ‘feature’ is directed towards those who already know how they’d make use of it, and I hope it makes them pretty happy. :)
A lot of libraries still don’t work on Ruby 1.9. I really have no idea what the status is of even the most popular projects, like Rails. That having been said, there’s nothing stopping you from firing of some 1.9 based shell scripts from Rails to generate your PDFs, though whether it makes sense to do that totally depends on your needs.
The good news is the future looks bright. By the time Prawn makes it into Ruport , Ruport itself will be Ruby 1.9 compatible. I bet you can expect most of your favorite libraries to slowly take the plunge, and eventually, Ruby 1.9 will become the platform of choice for running Prawn.
That having been said, we’ll support 1.8.6 forever, or at least for the forseeable future. I mostly just wanted to let our users know that you have options, and also use Prawn as a bit of bait to get you to try Ruby 1.9. It truly is a lot of fun, once you get used to it.
A huge thanks goes out to ruby-core for the release, and please let me know if you decide to try Prawn on 1.9. As always, keep those bug reports coming.
Written by Gregory Brown on 2009.01.30 at 14:07 | Responses