Concerning the term _monkeypatching_
There have been many "dark days" in the Ruby community, some much darker than others. Guy Decoux died, why the lucky stiff left us (without dying), Jim Weirich died. (Yes, I count actual deaths as the darkest moments of all.)
But I count another dark moment that many of you will not. When I had been using Ruby a little more than six years, in December 2005, the term "monkeypatching" was introduced into our circle.
It was a post by Drew Mills, quoting a blog from a Python person who apparently hated Ruby. I don't blame Drew. I don't suppose I "blame" anyone. But I regret that this slang has entered our culture.
The post Drew quoted was this:
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.
Before I go on to my main point, I'll make an observation that is arguably much more interesting. If you read again, it sounds like the Python person (Ian Bicking) was talking about dynamic method dispatch (the use or abuse of method_missing) rather than actual open classes.
Someone later in that thread decried the "ignorance" of Bicking with regard to this -- that he didn't even know enough Ruby to know the difference between dynamic dispatch and open classes. I wonder if the original pythonism meant something different? Since I never completed my Python studies, I can't comment.
At any rate: Back to my story.
I still recall the revulsion I felt, almost physical nausea, when I read this the first time. That's probably a somewhat extreme response on my part.
I regarded open classes as a programming technique that is potentially very powerful but easy to misuse. This sounds like a "good and yet bad" argument. But let me rephrase that sentence.
Open classes are a technique that is potentially very powerful and therefore easy to misuse. That is the point. Any tool that is powerful enough is prone to misuse by people who are unskilled.
The term "monkeypatching" is obviously a pejorative term. Upon seeing it, my first thought was, "I am not a monkey, and I am not 'patching' anything."
After all, that is the implication. The term implies that the developer is a monkey, and that the work he is doing is sloppy or shoddy. It is an insult both to the quality of the developer's work and to the developer himself.
So it bothered me because it was a pejorative and it was insulting to us as programmers. It was also (arguably) an insult to Ruby itself and therefore by extension an insult to Matz.
I dislike being clannish, though perhaps sometimes I am. After all, Ruby is not (supposed to be) anyone's religion or cultural heritage. It's only a programming language, and I think it's very much like Python. But it also bothered me that this neologism originated outside our community, in particular with the Python community.
Generalizations are always wrong. (Yes, that's a joke.) And stereotypes as such are at least useless if not actually hurtful. And yet I always heard about the arrogance and rudeness of Python programmers, and I occasionally saw real evidence of it. And though I dislike the word "nice" in general, I always found it interesting that Ruby coders were labeled as "nice" (as in the abbreviation MINASWAN, "Matz is nice, and so we are nice").
So when this usage was introduced, I felt rather as though someone had opened my front door and dumped a large piece of dog manure onto my carpet. What is worse, it has wormed its way into common usage in our community, even in documentation. A lot of this happened in the early days of Rails, when fate dumped a huge influx of newbies onto the Ruby community. Not to disparage the Rails people in general, but at the time this felt much the same as it did back when AOL (America Online) made its debut and dumped millions of (insert noun here) into the Internet and Usenet communities.
It's impossible to stop this usage now (like so many other usages in the English language having nothing to do with computing). But I still protest, and I still stand against it.
The term "monkeypatching" appears only once in more than 800 pages of The Ruby Way. It occurs when I say I don't condone this term, and it won't be used further in the book.
As an aside: The "refinements" which exist in recent versions of Ruby make open classes stricter and safer. I'll blog about that later. But this isn't much of a technical post. It's just a reminiscence and a rant.
So basically I hate the term "monkeypatching." I am polite to people who say it to me (e.g., in asking a question), but secretly I want to just ignore them.
The last time I saw Jim Weirich, in New Orleans, he and I talked about this. He agreed it was a pejorative term, and it was a shame it had entered the common dialect, though there was really nothing to do about it. But being much more level-headed and good-natured than I am, he wasn't bothered much by it.
I really miss Jim, by the way. He was a truly brilliant developer and an amiable and wonderful person in general. If it would bring him back, I would gladly change the book's name to The Art of Monkeypatching.