My analyst warned me, but metaprogramming was so beautiful I got another analyst
weblog.raganwald.com
weblog.raganwald.com
a) works with terrible programmers and
b) has no idea how to discern who the terrible programmers are.
In my case, it's simply "Hark! The clarion call of the librarian". ;)
There are good reasons to be careful of monkey-patching, especially monkey-patching of built in classes, but they are essentially identical to the reasons that you want to be careful of all global state. There are other forms of metaprogramming, such as macros or templates, which are more local and safe.
I guess the real issue is between "make potentially bad choices annoying and difficult to use, so that programmers feel bad about using them," versus "support all programming as well as possible, trusting the programmer to avoid bad patterns." I think that the latter attitude is more realistic: a determined bad programmer can write bad code even in Haskell or Ada or Java, and sometimes those "bad" patterns are useful (e.g., gotos are a great way to write a DFA).
I've personally come to the conclusion that without metaprogramming you really can't write decent frameworks; even Java frameworks tend to use reflection and even run-time code generation, and I think the lack of more capable metaprogramming abilities in Java is one reason frameworks in Ruby, Python, etc. are more user-friendly. Frameworks are crucial these days, so I think metaprogramming is also essential to a language. It's just something that ideally would be used only in cases, like frameworks, where only a few people have to actually understand and debug it and a large number of people can leverage that work.
He is objecting to dynamically changing some of the methods in the string class leading to subtle bugs as some code is written assuming the old string class and some using the new string class. Pheraps just explicitly define a separate custom-string class, or as he points out use mixins.
For those of us that actually know how to use powerful tools without cutting off our fingers... we have other blogs to read, and can safely ignore pretty much anything Atwood says. I even like XML a little more than I used to, just because he wrote a blog post against it ;)
If you freeze any moment in time then elitism always seems like the most rational choice. But if you take into account the passage of time then elitism is a losing proposition.
Thinking...
I don't know what Atwood really meant, it's just a blog post, but I do think there is a real distinction between "Hey you! Don't do that, it's dangerous!" and "You shouldn't be allowed to do that, you're not qualified."
After all, I wrote this:
http://weblog.raganwald.com/2008/04/is-strictly-equivalent-t...
Which is definitely a kind of "Don't do such and such" article. But while I actually write code to make things I like easier, I have no interest in sitting down and writing code to make the things I don't like harder or impossible.
However, if the "I hate thinking when I could be cutting and pasting" programmer is your blog's audience, it makes sense to agree with them. More ad revenue.
I don't really see this as elitism, I see it as reality. For what it's worth, I have no problem trying to educate these developers and turn them into good programmers. My blog is mostly instructional, I give free talks at every conference I can, and I teach paid classes if companies really want to make sure their developers learn good practices. Some people can be educated, and I am always happy when people realize that writing good code is fun.
However, some people really don't get what programming is about, and those people are going to criticize things that are "hard". (I really don't want to imply that Jeff Atwood is one of these types, but I don't really have any arguments disproving it.)
A deciding factor is the structure and process in which your organization works. Structures which work well for creating Java code probably won't work well for creating JavaScript or Ruby code. A couple of things come to mind:
1) Code reviews are a lot more important for languages which allow 'meta-programming'
2) Thorough, but concise documentation, also.
Extending Class.inherited() (as quoted in the linked article) without telling anyone or documenting it is a social problem of process and organization, not one with the programming language.
To stop code standing on other peopoles toes, namespaces and encapsulation were invented. In this case, there is no way to encapsulate the change to Class.inherited, it must be Global, because the language does not support anything else. If the language did support other possiblities, then the social problems would have been less acute.
So I felt the repsonse mirrored the original post.