On Dec 22, 2005, at 4:27 PM, Drew Mills wrote:

> Let me preface this post by saying that I'm no Ruby expert.  I like  
> it.
>  It's fun.  But I won't claim extensive knowledge on it.
>
> So when this guy blogs about a Python quality that he feel is better
> than a Ruby quality:
>
>     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.
>
>     -- http://blog.ianbicking.org/theres-so-much-more-than-rails.html
>
> I am curious what this means.  Is Python against dynamic stuff?  And
> Ruby for it?  And so we just agree to disagree?  Or do I  
> misunderstand?

Well, Python is plenty dynamic. I think he is complaining about  
Ruby's ability to re-open a class. This can make it difficult to find  
the complete definition of a class (imagine doing this in a  
completely random way in multiple files). So while it can be abused,  
it can also be an incredible simplification of the code you write.  
One thing it does is flattens inheritance hierarchies,  you don't  
need to introduce specialising classes just to add a few methods.  
Using xampl as an illustration: the Ruby version of xampl generates 1  
class for every 3 generated by the Java version of xampl, one of  
those classes is eliminated because I can re-open classes (the other  
is eliminated due to duck typing). Another thing reopening classes  
does is, obviously, to allow you to extend the built in Ruby classes  
(they are just classes after all). I suppose Ian would think things  
even worse because in Ruby you can do this to objects as well as  
classes.

This 'monkeypatching' is very similar to concepts in Smalltalk and  
CLOS (Common Lisp's object system). Nobody in those communities  
complains too much (though Smalltalk's browser reassembles classes  
for you, and new CLOS programmers are sometimes at a bit of a loss  
because in CLOS methods may belong to two or more classes and it  
doesn't seem that the obvious thing to do is the right thing). Ruby  
just makes thing a lot easier.

Just be careful where you aim that thing.

Cheers,
Bob

>
> Just curious.
>
> Drew
>
>

----
Bob Hutchison          -- blogs at <http://www.recursive.ca/hutch/>
Recursive Design Inc.  -- <http://www.recursive.ca/>
Raconteur              -- <http://www.raconteur.info/>