post

Afraid of Ruby 1.9
Afraid of Ruby 1.9

Ignore this post. I bit on an April fools joke that I read on April 6th. Way to pay attention. Anyway, the only valid point here is related to send, but that’s hardly a big deal.

I’ve come to absolutely love Ruby. I just love the syntax. But lately I’ve been reading a bit about Ruby 1.9, and it makes me a little worried about Ruby’s (and Rails’) future.

Here are a few of the methods being removed in Ruby 1.9:

  • method_missing—Yep, that’s right. No more method_missing. This is disastrous for Rails, as well as a good chunk of meta-programming practices. The argument is the same as it always is, too much abuse. But the dynamism of things like method_missing is what makes Ruby so exciting (and challenging), IMHO.
  • const_missing—Maybe not quite as important, but const_missing is getting removed for the same reason: too much abuse. I’ll admit, I’ve not used this one too much, but I’ve read about a few clever ways people are using it (unicode-based character escapes, for example).
  • send—And finally, send will no longer be available in Ruby 1.9. While there are more important things to worry about (see both bullets above), this is still something to deal with. I’m using send all over the place in all of my projects. The AR::Base.send(:include, RPH::Module) pattern is a commonality that can be found in most plugins. I believe there’s a drop-in replacement for send (I can’t remember what it is), so a quick fix would be to create an alias method (send) for the newly named version.

They say it takes 10 years or so to learn a programming language. Applying that logic to Ruby, I’m only 20% of the way there. So maybe these changes won’t hurt Ruby. Maybe they’ll be better for the language. I don’t really know. I’m a far cry from a language designer. But man, I’m having a rough time finding the positive with getting rid of method_missing and const_missing. Only time will tell, I suppose.

Maybe it’s time to see what advances PHP has made? Just kidding. Ruby had me at “Hello World”.

Comments
01
07 Apr 2008 08:10 AM

I’ve spent a bit of time googling this, but just wondering where you found out about each of those points—are these definitely being removed? (Or are they just not implemented yet…)

02
_eric
07 Apr 2008 09:04 AM

I can’t seem to find any of these in http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9

Where did you hear about these being removed?

03
DHH
07 Apr 2008 10:44 AM

The removal of method_missing and const_missing as an April Fool’s joke by someone. The removal of send is actually not a removal, but some syntactic vinegar. You can now do the same using send!.

So no cause for alarm or fear ;)

04
_eric
07 Apr 2008 10:55 AM

I was actually going to ask if this post was some sort of late April Fools joke. ;-)

05
07 Apr 2008 11:14 AM

I should have known.

I just went back and tried to find the original post, and it was gone. Since I knew it was in Google Reader somewhere, I scoured my ruby/rails feeds until I found it. Of course, the date is April 1, 2007. I read my feeds every 3-4 days anymore, so the dates are a little irrelevant to me. Plus, April fools really plays no part in my life, so I don’t always think about it.

Anyway, the link no longer exists (of course), but here’s the post that made me bite (courtesy of Chris Shea):

Check out the commit message from revision 15890 of Ruby’s trunk:

* eval.c: removed method_missing (too much abuse)

* variable.c: removed const_missing (see above)

This is pretty disconcerting. Part of what makes Ruby so great (at least in my opinion) is how malleable it is, and those two methods are a big part of that.

I don’t think it will be possible to add that functionality back into Ruby. Method and constant resolution will just fail, and we won’t be able to hook into it properly. Unless you want to wrap every constant and every method call in a begin block, rescuing the appropriate error, and slowing things down dramatically, you’ll just have to live with less dynamic code.

The future for frameworks and fun metaprogramming is bleak. Say goodbye to Rails on Ruby 1.9. Say goodbye to Merb, and DataMapper, and GuessMethod, and probably everything interesting done in this little love of ours.

It might even be time to say goodbye to Ruby. This is a sad day.

I should know better than to trust anything in the beginning of April. I should also know better than to believe method_missing was being taken away from Ruby!

Sorry for continuing the nonsense…




Please rewrite the image text in the SPAM field: Spam Protection

Preview

2008 by Ryan Heath | Get In Touch

flickr

DesolateInfinityLooking upDazedBlurred