Which version of ruby should we use and why?
4 Answers
Ruby 1.9.2 is stable, runs faster, and provides more essential features (such as good Unicode/multi-charset/multi-encoding support).
There is a broad and consistent push to get Ruby libraries and frameworks working well with Ruby 1.9.2. I only use Ruby 1.9.2, and almost everything I come across that I want to use supports Ruby 1.9.2. There remain some gems "out there" that are not compatible with 1.9.2, but, by now, that is the rare exception.
z3cko brings up Rails startup time. This is irrelevant. You will be starting Rails very infrequently. The runtime speed boost you get with 1.9.2 dwarfs the Rails startup boost you get with 1.8.7. Note that I have done no measurements.
z3cko also brings up REE. REE was good for the Ruby 1.8 line. But the Ruby 1.9 line uses a completely new VM which is already much better than the 1.8 VM. And if you want to use an alternative implementation of Ruby, try out JRuby or Rubinius, once these runtimes implement full 1.9.2 compatibility (both are currently fully 1.8.7-compatible and working on 1.9.2 compatiblity). Both of these alternative runtimes are better equipped to provide extraordinarily better performance: JRuby can take advantage of the HotSpot JVM, and Rubinius can take advantage of LLVM. Plus, JRuby has good integration with the JVM and lets you make use of Java libraries very easily. Additionally, REE is best when used with Phusion Passenger, but there are new ways of deploying Rails apps (Nginx in front of Thin or Unicorn) that provide strong benefits and which do not make use of Phusion Passenger.
The Ruby landscape is changing very rapidly, as is the Rails-deployment landscape. REE 1.8.7 with Phusion Passenger is solid. But we have newer, shinier, faster, slimmer, production-ready tools with which to cut, sharpen, and polish our infrastructures.

- 65,165
- 12
- 129
- 169
-
Everything I wanted to say and more. Eclipses my answer. – Lee Jarvis Jan 27 '11 at 23:36
-
Justice, can you point me to more information on nginx and unicorn/thin? what is the benefit over passenger? – z3cko Jan 27 '11 at 23:56
-
Heroku uses Thin. The chef `application` cookbook suggests using unicorn and provides samples of how to set it up, and this support specifically eclipses their prior support for Passenger: https://github.com/opscode/cookbooks/tree/master/application – yfeldblum Jan 28 '11 at 00:54
Well, 1.9.2 of course. Why? because it's the latest stable version. 1.9.2 is an improvement over 1.8.7. Speed, standard libraries, and of course more features. 1.8.7 is promoted too much, I don't see any reason to use it over 1.9.2*.
See this question for more exact differences.
*EDIT - z3cko brings up 2 good points. REE is certainly boasting with its speeds and agility for Rails applications. There are of course many gems which don't support 1.9.2, but there are also many gems which only support 1.9. Any author releasing a gem nowadays who expect people to use it in a production environment should be writing it with both 1.8 and 1.9 compatibility in mind.

- 1
- 1

- 16,031
- 4
- 38
- 40
-
I think you're overstating the gems that only support 1.9. To give you a counter example if you turn your attention to rubygems, you'll probably notice "RubyGems 1.4 has been released! Download here. Ruby 1.9+ users should wait to upgrade". Just my 2 cents here. – vise Jan 28 '11 at 00:02
-
RubyGems 1.5 was just released. It is compatible with the Ruby 1.9.2 and Ruby 1.9.3 (development) lines. Bundler 1.0.10 brings compatibility with, and was released just hours after, RubyGems 1.5. – yfeldblum Feb 01 '11 at 15:46
you should use ruby 1.8.7 - especially Ruby Enterprise Edition, if you are starting to develop. Most of the gems and examples you will find out there are for Ruby 1.8.7 (still, some gems are not fully 1.9.2 compatible).
Furthermore, as some people argue, benchmarks show that rails with 1.8.7 (REE) is still faster than Ruby 1.9.2 - and: Rails startup time is also slower with 1.9.x
I would advise waiting for 1.9.2 to mature and sticking to REE in the meanwhile. It might be a good time to switch to 1.9.x when there is a REE version for that Ruby branch.

- 3,054
- 8
- 40
- 59
I had some nasty segfaults with 1.9.1 (1.9.2 wasn't out at the time) on a basic rails app and reverted back to 1.8.7. Perhaps it was my environment, but right now I would worry about using it on a critical app.
One other argument (albeit subjective) for using 1.8.7 is that it's more likely that my code will run on 1.9.x then the other way around.
If performance is an issue, you'll probably want to use 1.9.x however most of the time the bottleneck is somewhere in the database (if you're using it on the web that is).

- 12,713
- 11
- 52
- 64
-
Noone suggested 1.9.1, Rails 3 doesn't work with anything but 1.8.7 and 1.9.2, so I think anyone would worry about using 1.9.1 for **anything**. 1.9.2 is fine, though. Agreed with the second point – Lee Jarvis Jan 28 '11 at 00:10
-
Indeed, I stand corrected on point one. However I would still use a proven solution over the latest and greatest on a serious project. – vise Jan 28 '11 at 00:26
-
The Rails 3.0 release was specifically delayed until Ruby 1.9.2 was released, because of some problems (including nasty segfaults) with Ruby 1.9.1 that were fixed in Ruby 1.9.2. Ruby 1.9.1 was released well before serious projects started hammering away at it. Ruby 1.9.2 was released in response to all of the feedback that serious projects provided on the 1.9 series, and dealt specifically with any stability problems remaining in the 1.9.1 series. – yfeldblum Jan 28 '11 at 00:50