5

I’m a complete non-programmer who is learning to program with Ruby and the Rails framework.

I’m currently using Ruby 1.8.7 and Rails 3.0.3, but I’m wondering if I should upgrade to Ruby 1.9 since I don’t really have any “legacy” costs with upgrading.

What’s the downside? Am I going to run into compatibility issues with common gems, or even other issues that I don’t know enough about to even anticipate?

Joe Doyle
  • 6,363
  • 3
  • 42
  • 45
Brennan
  • 71
  • 4
  • Welcome to the development world. It's a constant puzzle but if you enjoy mental challenges you'll find them writing code. – the Tin Man Mar 16 '11 at 18:56

5 Answers5

4

You should upgrade. Don't stick start with 1.8.7. If you find gems that don't support 1.9.2 avoid them (as they are most likely not maintained). If you have any questions over whether or not a gem is 1.9.2 compatible you can look it up at: http://www.railsplugins.org/. If you are running a UNIX based system you can easily upgrade with http://rvm.beginrescueend.com/.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232
  • Ruby-prof has some issues with 1.9, and I wouldn't call it an unmaintained project. – Andrew Grimm Mar 16 '11 at 23:24
  • @Andrew Yeah, I seem to remember the SVN copy is able to compile in 1.9 as well as a few forks but I do see they have a few open issues for it on their GitHub page. Seems like something the maintainers should fix. – Kevin Sylvestre Mar 16 '11 at 23:33
3

Ruby 1.9 has superior performance, real threads and support for different character encodings, for starters.

Lots of things changed, which caused incompatibility, but since that's not a problem for you, yes, you should use Ruby 1.9.

Here's a nice slide show that lists significant changes.

Matheus Moreira
  • 17,106
  • 3
  • 68
  • 107
2

You may run into some compatibility issues, but most common gems are ported to ruby 1.9. If I were you I would stick to 1.8.7, especially if you're learning. This way you avoid all the confusion with: "Is this my error or just ruby 1.9 incompatibility"

And btw, if you haven't programmed before I don't think this is a good idea to start with rails. Go learn pure ruby first, implement some algorithms in console, connect to a database with no activerecord. I just think that starting with rails will hide too many details, and this will kick you in the ass later when you end up lacking in basic knowledge...

michaelmichael
  • 13,755
  • 7
  • 54
  • 60
Adrian Serafin
  • 7,665
  • 5
  • 46
  • 67
  • 1
    What about the gems that are only 1.9 compatible? This seems like a bad reason to avoid upgrading, especially given what an improvement 1.9.2 is over 1.8.7. – Kevin Sylvestre Mar 16 '11 at 18:36
  • I will agree with you if it was just about ruby or if Brennan had some programming expierience... I think that he will make enough wierd errors on his own, without compatibility issues ;) but that's just my opinion – Adrian Serafin Mar 16 '11 at 18:42
  • 1
    I doubt he'll run into compatibility issues with gems when starting out. Beginners rarely look for esoteric/niche gems since their needs are pretty basic. I run 1.9.2 on several flavors of Linux, plus Mac OS and have only found one gem that had problems. Everything else I use for enterprise and person development has worked fine for a long time. – the Tin Man Mar 16 '11 at 18:55
  • The reason I asked this question is because I was debating whether my next read should be "Programming Ruby 1.9" or "1.8.7." I really debated learning rails vs. ruby first with friends. The responses were a mixed bag. I've been through 2 rails books (railstutorial.org and Agile Web Development with Rails) which I think helped me get my bearings and get excited about building something, but now I'm ready to strengthen my foundation. – Brennan Mar 17 '11 at 15:58
1

You should upgrade. Not so much because of gems (as it will take some time until you start using some other than those you get with Rails), nor because 1.9 is so much superior to 1.8 (because it isn't). You should upgrade because, during course of learning, you will inevitably bump into some code (for example, here on SO) that won't work on 1.8, because of some nuance that was introduced in 1.9 - trivial example being shorthand hash notation: {foo: 1, bar: 2} (as opposed to traditional {:foo => 1, :bar => 2}).

Mladen Jablanović
  • 43,461
  • 10
  • 90
  • 113
0

Ruby 1.9 has new features that are crucial. You can write a regular expression in ruby 1.9 that lets you find balanced parenthesis, for example. This was hard to do in ruby 1.8. It is also much faster. It is also convenient to use 1.9; it has lots of built in methods in Array and Hash, which you had to write by yourself in 1.8. You should not use ruby 1.8; use ruby 1.9.

sawa
  • 165,429
  • 45
  • 277
  • 381
  • Isn't it was impossible to check for balanced parenthesis in a regular expression? I always thought this was the classic example of when regular expressions fail (i.e. requires use of a stack). Do you have an example of doing this in Ruby 1.9.2? – Kevin Sylvestre Mar 16 '11 at 18:45
  • I didn't write it's impossible. I wrote it is difficult. Please read my comment carefully. I have actually written that in the past when I was using ruby1.8. But you can't do it in a single regular expression. – sawa Mar 16 '11 at 18:49
  • @sawa You wrote 'you can write a regular expression ... that lets you find balanced parenthesis'. This is impossible in any language. – Kevin Sylvestre Mar 16 '11 at 18:51
  • @Kevin You don't seem to know the features of oniguruma. Read this: http://www.siaris.net/index.cgi/Programming/LanguageBits/Ruby/Oniguruma.rdoc – sawa Mar 16 '11 at 18:54
  • @sawa Interesting. I guess it uses recursive regular expressions. I found: http://stackoverflow.com/questions/133601/can-regular-expressions-be-used-to-match-nested-patterns and was based on that. – Kevin Sylvestre Mar 16 '11 at 23:19
  • I think you (and some people on the thread that you cited) are confusing regular expressions with regular grammar/languages. Even though the term regular expression might have derived from regular grammar, most of modern regular expressions already exceeds the capacity of regular grammar. For example, introducing the counting operator `{m,n}` already goes beyond regular grammar. – sawa Mar 17 '11 at 01:04