Brandon Craig Rhodes: "Ruby people do this. Monkey patching: F".
In fairness to Ruby people, Zope and Python people have been monkey patching for years (that's where the term comes from). I only know this because I've been in the 8th ring of Zope2/Plone hell, which is where all the monkey patchers go, and they are legion (the 9th circle is reserved for those who hack zcatalogs - a story about that some other day). Object Adapters get a B from Brandon because he says the wrapping is annoying - and he's right, it is annoying, even though it's my reflex pattern for binding domain objects into Atom/AtomPub. Gone wrong you end up with parallel hierarchies and implicit mappings and a lot of noise - Brandon has a picture in his presentation that captures that perfectly.
Personally, I've always felt that Zope2 is a possible anti-future for Rails. And I suspect there is a cultural difference in emphasis between Python and Ruby insofar as the Python community tends to frown on monkey patching, even though it's their "fault":
Ian Bicking: "It's the second generation that's going to be less enthused, that's going to stare in bafflement at these classes that mysteriously spawn methods, and trying to figure out what's going when there's an exception in dynamically generated code. You can monkeypatch code in Python pretty easily, but we look down on it enough that we call it "monkeypatching". In Ruby they call it "opening a class" and think it's a cool feature. I will assert: we are right, they are wrong."
Chad Fowler: "But this 'monkey patching' thing is seriously powerful and, as an end-usre [sic] in this case, I can say that it makes things better for the users of Ruby."
Suggestion: if you're a Rails fan, take at look at Brandon's presentation: http://rhodesmill.org/brandon/static/2008/grok-walk-duck.pdf It gives a quick overview of Zope3's Component Architecture (ZCA) It's easy to be dismissive, but therein Zope3 captures a decade's worth of lessons learned from trying to deal with large monkey patched codebases written in a dynamically typed language. It's hard to figure out the real size of a Zope2 install because it's component/product based, but ohloh.net has it at 500Kloc - Rails according to ohloh.net is passing 100Kloc. Am I saying monkey patching doesn't scale with line count? Sort of.
If there's a downside to the Zope3 approach, it's that ZCF gives you a shadow object model alongside Python inheritence, and that can be confusing. ZCML is also noisy, but Grok seems destined to make that go away - vaguely similar to Spring XML wiring versus Guice's in-code approach.
7 Comments
Quite on target. I like the title best: is it "Zope on Rails", or is it "give'em enough rope..."? :-)
Nicola, it's both )
Side note: monkeypatching is a dangerous name.
I used the term around my boss, and he thought I was using a racial slur. It was very awkward.
See also http://avdi.org/devblog/2008/02/23/wh...
Bill Mill: I've seen an alternative in the Ruby community that captures the negativity without a racial slur (at least I don't think there is one there): Duck Punching.
How bizarre. I think someone finding 'monkey patching' to be a racial slur is the person with a racist attitude. Whilst I don't think that the concept of 'race' is at all helpful or precise when thinking about human differences and similarities, the idea that any 'race' of people has any resemblance to monkeys is beyond me. Mind you, perhaps this association of 'monkey' with racism is more an American thing.
McuW9R <a href="http://gmtwfqwdotbo.com/">gmtwfqwdotbo</a>, [url=http://jpfauptgvjdw.com/]jpfauptgvjdw[/url], [link=http://iwcbjwgswilc.com/]iwcbjwgswilc[/link], http://hiygljcphbji.com/