# Monkeypatching is Destroying Ruby

**URL:** <https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992>\
**Category:** Ruby\
**Created:** [February 23, 2008, 10:08pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992 "2008-02-23T22:08:27Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 6:13pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/61 "2008-02-26T18:13:47Z")

</div>

On Feb 26, 10:45 am, “Jones, Brian - McClatchy Interactive”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d be at least a little interested in potentially offering developers  
> the chance to ‘lock’ their classes from monkey patches. This could be  
> useful to the ‘core’ library that comes with Ruby, and to at least make  
> developers look at extension points provided via an actual API instead  
> of just immediately jumping on monkey patching for solving all problems.

That’s ridiculous.

Look. What is the problem? That I might extend a class and you might  
extend a class with the same method and thus we can’t use each others  
code in the same program? Forget overriding core/standard methods –  
anyone who does that knows they must do so with SUPER EXTREME caution.  
But if someone is writing and end-user application, it doesn’t really  
matter one way of the other --the code is not intended to be shared.  
Extend to your hearts desire. One only needs to be aware of potential  
conflicts with 3rd party libs they might use. And for those, in which  
the developer is intending for their code to be reusable, then the  
developer needs to tread more carefully and follow some simple rules.  
Only extend core and standard classes when it’s a very clear and  
general need. In which case it’s a good idea to checkout projects that  
attempt to provide some general standardization around such methods  
(eg. Facets). It’s likely your method is already available, and your  
lib’s users can have a reasonable basis for knowing what to expect.  
Beyond that, if you still really want to extend a core/standard class  
in a way vunique to your particular program then give it an equally  
unique name --generally putting you project’s name as the first part  
of the method. For example, the YAML lib adds methods like  
#yaml\_properties.

By following these rules, getting along with other programs is a  
pretty safe bet. And we don’t need to add restrictions that will just  
make life harder when we do have good reasons to MP.

I should point out one other rule of thumb often overlooked as a  
consequence of MP: DO NOT use #respond\_to? as a means of determining  
if an object is extended by a module or is an instance of some class/  
superclass. That’s much more likely to lead to unexpected issues with  
MPs.

T.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 7:26pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/62 "2008-02-26T19:26:16Z")

</div>

Trans wrote:

> On Feb 26, 10:45 am, “Jones, Brian - McClatchy Interactive”  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I’d be at least a little interested in potentially offering developers  
> > the chance to ‘lock’ their classes from monkey patches. This could be  
> > useful to the ‘core’ library that comes with Ruby, and to at least make  
> > developers look at extension points provided via an actual API instead  
> > of just immediately jumping on monkey patching for solving all problems.
> 
> That’s ridiculous.

Fears about open classes sound very much like what people say about  
dynamic typing.

“#{@core\_feature} is unpredictable!”

“#{@core\_feature} creates problems that cannot be found until run-time!”

“#{@core\_feature} is unsafe!”

“#{@core\_feature} should be locked down!”

It’s not that these claims are entirely untrue, it’s just that, in real  
life, most people simply do not encounter the alleged problems.

Code that is poorly written or does not play well with others tends to  
get discarded.

–  
James B.

“Trying to port the desktop metaphor to the Web is like working  
on how to fuel your car with hay because that is what horses eat.”  
- Dare Obasanjo

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 7:33pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/63 "2008-02-26T19:33:20Z")

</div>

On Tue, Feb 26, 2008 at 9:09 AM, John W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> data = case obj
> when Array
> CSV::from_a( obj )
> when Hash
> CSV::from_hash( obj )
> else
> raise "Sorry, I'm not duck-type friendly!"
> end
> 
> ```
> 
> end
> 
> Yuck.

Point taken. Monkey patching might be the best solution in this  
situation.  
Assuming you want to be able to convert any arbitrary object to a CSV,  
this  
might be best.

Another possibility would be something like this:

module CSV  
From = {  
Array =\> proc {|a| …}  
Hash =\> proc {|h| …}  
…  
}  
…

Then use CSV::From[obj]. The problem is that if you build a class later  
that wants to work with CSV, you’d need to modify this CSV::From  
“global”.  
This “global” modification isn’t much better than monkey patching  
“global”  
modification.

I think John does illustrate why monkey patching can be useful with  
duck-typing. In statically-typed languages (like C++), the above can be  
solved by overloading a global function based on type (type should  
prevent  
collisions). Don’t take this to mean I want static-typing. I’m the  
biggest  
fan duck-typing.

Still, we should not use monkey patching as our first tool. We should  
think  
of it just like global variable modification, IMO.

Eric

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/64 "2008-02-26T19:18:36Z")

</div>

Jari W. wrote:

> John W. wrote:
> 
> > > The disadvantage of making Array#to\_csv is that you are  
> > > modifying a global “variable” (the Array class).
> > 
> > I’ll take that disadvantage (in combination with good test coverage!)  
> > over having to write verbose, type-checking code any day.
> 
> IMO, this is not an either/or case. Why not just add to\_csv() only to  
> the instance who actually could need it?

How far in advance do you know that an instance needs this method?

If you wait too long, you end up with another case statement (again, on  
the class of the object, yuck) to decide which #to\_csv is appropriate  
for the object.

If you add #to\_csv eagerly, then the requirement that this object  
respond to #to\_csv becomes a strong coupling between the point of  
creation and the #i\_need\_csv implementation.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 7:44pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/65 "2008-02-26T19:44:32Z")

</div>

On Tue, Feb 26, 2008 at 1:25 PM, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> It’s not that these claims are entirely untrue, it’s just that, in real  
> life, most people simply do not encounter the alleged problems.
> 
> Code that is poorly written or does not play well with others tends to  
> get discarded.

Except that I’m working in the real world, and I run into these  
problems practically every day. Read through some Rails plugin code  
sometime - nearly every significant, popular Rails plugin does what it  
does by re-opening classes. Probably because this is the coding style  
that Rails demonstrates and encourages. Now we can argue about this  
being a Rails problem rather than a Ruby one, but again, that’s where  
people are learning the language these days.

If you have the luxury of working on small projects with few  
developers and the time to develop everything in-house rather than  
relying on third-party gems and plugins, that’s great. But I and the  
people I know _are_ encountering these problems. And in the majority  
of cases, they are _completely_ _avoidable_. And there is usually  
nothing about the problem that makes a monkey-patch a desirable or  
even an easier way to implement the feature - it’s simply done that  
way because that’s how everyone else is doing it.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/66 "2008-02-26T19:45:43Z")

</div>

Joel VanderWerf wrote:

> How far in advance do you know that an instance needs this method?
> 
> If you wait too long, you end up with another case statement (again, on  
> the class of the object, yuck) to decide which #to\_csv is appropriate  
> for the object.
> 
> If you add #to\_csv eagerly, then the requirement that this object  
> respond to #to\_csv becomes a strong coupling between the point of  
> creation and the #i\_need\_csv implementation.

I don’t think it would matter in this case. You should be able to create  
a dynamic implementation without case statements, since a CSV  
implementation would be dependent on the #to\_a method? (And #to\_a for an  
array object just returns self.)

Best regards,

Jari W.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 8:12pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/67 "2008-02-26T20:12:12Z")

</div>

On Wed, 27 Feb 2008 00:45:27 +0900, “Jones, Brian - McClatchy  
Interactive” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d be at least a little interested in potentially offering developers  
> the chance to ‘lock’ their classes from monkey patches.

You can do this today if you want; all you need to do is freeze the  
class.

class Foo

# … your definitions

end

Foo.freeze # Foo is no longer an open class

-mental

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 26, 2008, 11:31pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/68 "2008-02-26T23:31:00Z")

</div>

Pit C. wrote:

> Could you describe “the general thing” a little bit more? As I  
> understood it, he wants to limit a “monkey patch” to the scope of a  
> Module. Which is what I’ve done. I’ve only used the import-module  
> library and added a more user-friendly syntax. I’m not inspecting  
> caller at all, and import-module doesn’t either. What am I missing?

Well, I can’t find import-module-extended, but assuming it’s like  
import-module… you’re missing:

- performance
- isolation of instance variables that the extensions might create
- ability for an extended class to _always_ appear extended when  
called from anywhere in a class that knows about those extensions,  
without having to constantly remember to add the extensions on each  
call.

Is that enough to claim “no sensible way” of doing it?

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 3:45am UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/69 "2008-02-27T03:45:35Z")

</div>

On Feb 26, 11:34 am, ThoML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> […]  
> My point rather is this should somehow be standardized, i.e. the standard  
> library should provide standard means to do this.

This is what I was attempting to say in my previous post on this  
thread. You mentioned defadvice, which is a good example of a “long  
reach” mechanism employed by top-level code in order to tweak lower-  
level code. The reason this thread exists is because there is no  
centralized mechanism in ruby to help programmers from stepping on  
each others’ toes. Making ad hoc modifications to base-level classes  
is not a scalable practice.

So I will ask my question again: Is (or was) there a serious plan for  
something like selector namespaces in ruby 2.0? I found

> **[WebMD - Better information. Better health.](https://www.webmd.com/)**
>
> The leading source for trustworthy and timely health and medical news and information. Providing credible health information, supportive community, and educational services by blending award-winning expertise in content, community services, expert...

which appears to be down; google cache:  
[http://64.233.169.104/search?q=cache:ej4aPcNY41QJ:rubygarden.org/ruby/page/show/Rite+http://rubygarden.org/ruby/page/show/Rite&hl=en&ct=clnk&cd=1&gl=us](http://64.233.169.104/search?q=cache:ej4aPcNY41QJ:rubygarden.org/ruby/page/show/Rite+http://rubygarden.org/ruby/page/show/Rite&hl=en&ct=clnk&cd=1&gl=us)

Responses such as “What is the problem?” come from those who have been  
lucky enough to evade these issues in their own work. But eventually  
one will wish to use some code written by someone else which  
introduces conflicts. It’s only a matter of time, unless you  
personally write every line of code in your project. So the answer to  
“What is the problem?” is that the technique doesn’t scale.

–FC

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 6:57am UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/70 "2008-02-27T06:57:46Z")

</div>

On Tue, Feb 26, 2008 at 4:52 PM, James G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Feb 26, 2008, at 9:45 AM, Jones, Brian - McClatchy Interactive wrote:
> 
> > I’d be at least a little interested in potentially offering developers  
> > the chance to ‘lock’ their classes from monkey patches.
> 
> There are probably ways around this, but:  
> Hmm I do not think that one can overrule freeze; I never found a way,  
> anyone else?  
> Cheers  
> Robert  
> –  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

Whereof one cannot speak, thereof one must be silent.  
Ludwig Wittgenstein

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 7:13am UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/71 "2008-02-27T07:13:37Z")

</div>

Robert D. wrote:

> Robert  
> You can monkeypatch Class#freeze, as long as you get there first 😉

class Class  
def freeze; end  
end

class Foo  
def bar; end  
end

Foo.freeze

class Foo  
def zap; end  
end

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 12:37pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/72 "2008-02-27T12:37:44Z")

</div>

On Feb 26, 9:44 pm, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> centralized mechanism in ruby to help programmers from stepping on  
> each others’ toes. Making ad hoc modifications to base-level classes  
> is not a scalable practice.
> 
> So I will ask my question again: Is (or was) there a serious plan for  
> something like selector namespaces in ruby 2.0? I foundhttp://rubygarden.org/ruby/page/show/Rite  
> which appears to be down; google cache:[http://64.233.169.104/search?q=cache:ej4aPcNY41QJ:rubygarden.org/ruby](http://64.233.169.104/search?q=cache:ej4aPcNY41QJ:rubygarden.org/ruby)…

Solutions to this tend to be pretty weighty. Ruby is already a rather  
slow language. A while back I suggested this idea:

module MyModule  
class String \< ::String  
def something; “something”; end  
end

```
def self.tryme
  "string".something
end

```

end

def tryme2  
“string”.something  
end

MyModule.tryme #=\> “sometging”  
tryme2 #=\> NoMethodError

Austin thought it was the worst idea in the world. He may be right,  
I’m not sure. In either case it would add another level of  
consideration to the language.

> Responses such as “What is the problem?” come from those who have been  
> lucky enough to evade these issues in their own work. But eventually  
> one will wish to use some code written by someone else which  
> introduces conflicts. It’s only a matter of time, unless you  
> personally write every line of code in your project. So the answer to  
> “What is the problem?” is that the technique doesn’t scale.

What technique is perfectly scalable? There is always the potential of  
name clash no matter what technique is used. It’s an unfortunate fact  
of life, but if the library you are trying to use is poorly written –  
well, then life sucks. Fix the library or find another.

I think you may be looking foe a magic bullet that doesn’t exist.  
Also, do you have examples of this issue?

T.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/73 "2008-02-27T14:31:22Z")

</div>

On Tue, Feb 26, 2008 at 7:25 PM, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Code that is poorly written or does not play well with others tends to  
> get discarded.

We still have Gems, which don’t play well at all with others (on a  
technical basis) - witness the conflicts with the Debian team, and  
what every other Unix package maintainer says about this. This proves  
that this mechanism doesn’t work so well if there is a size/momentum  
advantage.

Also, discussing what is appropriate and not is a good way to educate  
people, and to help us all learn to think more clearly in the area.

Eivind.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 2:47pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/74 "2008-02-27T14:47:58Z")

</div>

On Feb 24, 2008, at 10:02 PM, James G. wrote:

> On Feb 23, 2008, at 4:23 PM, Eric M. wrote:
> 
> > I usually only do monkey patching in the  
> > following cases which have no reuse: top-level script, testing, and  
> > quick hacking.
> 
> I think it’s the ideal tool for adding compatibility methods.

Along these lines, I read a chapter in Design Patterns in Ruby last  
night that suggests using Ruby’s open classes as one possible way to  
implement the Adapter pattern. The book includes a pretty good  
discussion of the plusses and minus to this approach and makes  
recommendations about when it’s probably worth the trade-off. It’s a  
good read.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/75 "2008-02-27T15:21:41Z")

</div>

> Except that I’m working in the real world, and I run into  
> these problems practically every day.

It may be enough to simply have ruby warn us when and where a class has  
been re-opened and a means to ignore it by file/path or namespace if we  
want.

Brian

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 3:39pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/76 "2008-02-27T15:39:22Z")

</div>

On Wed, Feb 27, 2008 at 7:46 AM, James G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Along these lines, I read a chapter in Design Patterns in Ruby last  
> night that suggests using Ruby’s open classes as one possible way to  
> implement the Adapter pattern. The book includes a pretty good  
> discussion of the plusses and minus to this approach and makes  
> recommendations about when it’s probably worth the trade-off. It’s a  
> good read.
> 
> James Edward G. II

I don’t have the book. I wouldn’t mind seeing the +/- list.

You are talking about this, right?

> **[Adapter pattern](https://en.wikipedia.org/wiki/Adapter_pattern)**
>
> In software engineering, the adapter pattern is a software design pattern (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface.: 244  It is often used to make existing classes work with others without modifying their source code. An example is an adapter that converts the interface of a Document Object Model of an XML document into a tree structure that can be displayed. The adapter design p...

Using what this link above suggests (adapter “has-a” or “is-a” adaptee)  
is  
the better way to go, IMO. There are multiple ways to do this in Ruby.  
Monkey-patching/open-classes makes the solution: adapter IS adaptee. I  
don’t know if you can even call it the adapter pattern since you are  
destroying the adaptee interface.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/77 "2008-02-27T16:02:39Z")

</div>

On Feb 27, 2008, at 8:38 AM, Eric M. wrote:

> > > > quick hacking.  
> > > > James Edward G. II
> 
> I don’t have the book. I wouldn’t mind seeing the +/- list.

I don’t think I would do it much justice condensing it down for this  
email, but it basically amounted to how well you know the code you are  
adapting and how simple the changes are. The author felt it was  
probably OK if you knew the class involved well and you were just  
aliasing a method or two. Again though, I’m grossly simplifying here.

The book also talked about adding the methods needed to the singleton  
class of individual objects. I thought that was an awesome twist that  
we probably don’t consider enough.

> You are talking about this, right?
> 
> [Adapter pattern - Wikipedia](http://en.wikipedia.org/wiki/Adapter_pattern)

Yes.

> I don’t know if you can even call it the adapter pattern since you are  
> destroying the adaptee interface.

I view it as a Ruby way to think about the problem. Don’t they always  
say that intent is the most important aspect to the design patterns?

James Edward G. II

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/78 "2008-02-27T16:07:22Z")

</div>

On Feb 27, 8:30 am, “Eivind E.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Tue, Feb 26, 2008 at 7:25 PM, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Code that is poorly written or does not play well with others tends to  
> > get discarded.
> 
> We still have Gems, which don’t play well at all with others (on a  
> technical basis) - witness the conflicts with the Debian team, and  
> what every other Unix package maintainer says about this. This proves  
> that this mechanism doesn’t work so well if there is a size/momentum  
> advantage.

I would now suggest that it is the FHS that is holding us back, not  
the other way around --talk about your size/momentum advantage.

Suggested reading:

[GoboLinux - the experimental Linux distribution](http://gobolinux.org/index.php?page=doc/articles/clueless)

> Also, discussing what is appropriate and not is a good way to educate  
> people, and to help us all learn to think more clearly in the area.

Very true.

T.

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/79 "2008-02-27T17:36:37Z")

</div>

2008/2/26, Clifford H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Well, I can’t find import-module-extended, but assuming it’s like  
> import-module… you’re missing:

Clifford, thanks for listing your requirements.

> - performance

Comparable to other AOP frameworks in Ruby. That might be an obstacle  
for you, but it’s not for me yet.

> - isolation of instance variables that the extensions might create

If you are really serious about this, there are ways to achieve this  
goal.

> - ability for an extended class to _always_ appear extended when  
> called from anywhere in a class that knows about those extensions,  
> without having to constantly remember to add the extensions on each  
> call.

Please look at my sample code again. It does exactly what you describe.

> Is that enough to claim “no sensible way” of doing it?

Not for me, as I said above. But since there’s no formal definition of  
“sensible ways”, there might be no sensible way for you. Maybe we  
should take this to another thread or to private mail if you want to  
discuss it further.

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![avdi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@avdi](https://www.ruby-forum.com/u/avdi)\
**Post date:** [February 27, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992/80 "2008-02-27T18:43:20Z")

</div>

On 2/27/08, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > what every other Unix package maintainer says about this. This proves
> 
> > Also, discussing what is appropriate and not is a good way to educate  
> > people, and to help us all learn to think more clearly in the area.

In the case of Debian and Gems, I think it’s a mixture of a somewhat  
draconian interpretation of the FHS, and a desire to make the gems  
themselves somehow work like debian packages, which don’t envision  
things like having multiple versions of a gem installed concurrently.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

[Previous page](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992.md?page=3)

[Next page](https://www.ruby-forum.com/t/monkeypatching-is-destroying-ruby/129992.md?page=5)
