ZOMG! Ruby has a feature that can be misused!

It’s like the mother in the film A Christmas Story, warning Ralphie about the Red Ryder B.B. gun.

“You’ll shoot your eye out!”

Open classes is a feature.

Get over it.

9 Responses to “Monkey Poaching is Distracting Ruby”

  1. Eric Says:

    Well the point of Avdi Grimm’s essay is not that monkey-patching can be misused but that it is too often being misused, that people are reaching for that tool first when other tools may work better and/or create fewer problems.

    The poster is trying to change the Ruby culture by consolidating his arguments into an essay in the hope of spurring discussion. If writing such an essay is not the best way to change the culture, what would you recommend instead?

  2. James Says:

    ” ... but that it is too often being misused, that people are reaching for that tool first when other tools may work better and/or create fewer problems.”

    I haven’t seen that. Maybe it’s a Rails culture thing.

    Part of the problem is that people learning Ruby are not exposed to the metaprogramming aspect right away. So it gets treated either as a cool new toy, or something scary and mysterious. Hence the dopey name for open classes and runtime class modification.

    At worst, though, poor coding might be ruining specific apps or libs. It’s hardly destroying Ruby.

  3. Avdi Says:

    I knew I was going to live to regret the title of that article. It was, as I have said a few (dozen) times, intentional hyperbole, as well as an obscure reference to a Steven Colbert segment that was rattling around my brain at the time.

    Eric is right about what I was getting it – it’s not that I’m against a powerful feature (hell, my contributions to UtilityBelt are nothing BUT monkeypatches, but then, that’s kind of the point of UB). I’m seeing more and more good Ruby coders re-open classes in their gems and plugins without even considering an approach that uses, say, mixins. Yes, it’s currently more common in Rails (where re-opening e.g. ActiveRecord::Base is simply the accepted way to add a feature); but more and more rubyists are coming in from Rails.

    In conclusion, nice shirt :-)

  4. James Says:

    “Yes, it’s currently more common in Rails (where re-opening e.g. ActiveRecord::Base is simply the accepted way to add a feature); but more and more rubyists are coming in from Rails.”

    Well, yet another reason people should be told more about Ramaze and Nitro.

  5. Joe Grossberg Says:

    You’re both right—it’s a feature, but one that can be easily abused.

    Time will tell whether or not monkeypatching actually does more harm than good.

  6. rick Says:

    Rails itself uses mixins to add to ActiveRecord::Base.

  7. she Says:

    Avdi, but you claimed something that simply is not true. And you equal ruby community with the rails community.

    If you want to be fair, you do acknowledge that these communites are not the same. They may overlap, but I for example use 0 rails. I do however stay in contact with many other rubyista on IRC and I endorse their solutions, code, and frameworks.

    This is a model which is totally different to the hive-mind in rails where the master DHH serves in to his obedient army of zombie thinkers.

    And whenever someone out of the zombie thinkers equals ruby with the rails community, you cant be surprised to have people irritated.

    Ruby empowers. If you abuse something in ruby, your problem.

    Dont make this a problem that everyone in the community has by claiming that “metaprogramming” is destroying ruby.

  8. James Britt Says:

    I saw that this post is linked from Giles Bowkett’s site site, and since I saw no way to leave a comment there, I just want to say I’m puzzled anyone would consider my response to the whole monkey poaching thing to be “pissed off.”

    I’m mostly entertained, but disappointed that the poor coding habits of a segment of the Ruby community are taken as a harbinger of doom. Also a bit concerned that misnomers will impede understanding.

    The funny part is that the T-shirt design is old, motivated by one of many prior discussions warning that Ruby is too open and free, hence (in the opinion of some) too dangerous.

    This too shall pass.

  9. Arya Says:

    It’s interesting that some people complain and whine about “monkey patching” even though they can simply choose not to use the software that does it if they don’t like it. If you’re scared of monkeys, don’t go in the jungle.

    I posted my full spiel about this on my blog:

    http://www.unboundimagination.com/Monkey-Patching-Galore

Sorry, comments are closed for this article.