ActiveSupport Considered Harmful
hayesdavis.net
hayesdavis.net
It strikes me that what's really harmful here is the glacial pace of change in the Ruby Standard Library. Of course, we shouldn't see untried and untested functionality shoved into the standard library willy-nilly: pollution of the standard library with ill-thought-out code is probably even worse.
But, that said, Rails 1.0 came out almost five years ago. In the same time span, we've seen the release of Ruby 1.8.4-7 and 1.9.0 and 1.9.1. It was big news in 2007 when Rails' Object#tap method made it into 1.8.7 and 1.9.
We should be seeing more of this functionality pulled out of ActiveSupport and pushed into the Ruby Standard Library.
Backwards compatibility isn't optional here. Ruby could very, very quickly become a giant ball of hair if we're not careful what we put in, because nothing can come back out. Rails plays fast and loose with this, but having the language itself do so is really, really bad.
In summary, you mark a method as "implicit" which constructors a decorator object with your extension methods. Implicits must be explicitly brought into scope and any ambiguities are a compile time error. This model is much more robust than Ruby's, but owes a lot of it's error-prevention to clever use of static typing.
[1, 2, 3].as.sumUgliness.
I have commented on this issue a while back (http://bit.ly/cNez8i), and some people were kind enough to fork ruby (http://gist.github.com/358467) and enable scoped Open Classes, like Scala, Groovy and C# have. This is great for dsls (many dsls that change base classes can happily live in the same project without conflicting with each other) and libraries (I can do whatever I want in my library, extending Object, Enumerable and Kernel, left and right, and the users will not be affected).
However, this very openness made the "moving to a newer and better version of ruby" movement harder. Just hope 2.0 will set things right.
Disclaimer: open classes are great. I think they should be allowed, only highly discouraged for libraries and frameworks, who should stick with scoped open classes for most of the time.
Interestingly, Facets (a non-Rails support library similar in scope to AR) has exactly the same problem. So mostly this is an argument against similar broad support libraries outside any specific scope.
That is, Facets would be pointless by this argument because it has no Rails-like environment to live in.
It's correct that I'm essentially arguing against requiring "invasive" support libraries that change the nature of ruby (admittedly, that's subjective) in gems. Gem authors should consider their dependencies on the basis of necessity, not convenience. Keep the scope low and compatibility high.