Ironically, the example actually demonstrates the limitations of boo’s macros, rather than their power. Let’s start with the requirement to prepend method names with an underscore. It shouldn’t be too hard to make it use a dot just like VB, should it? Well, no, an expression that began with a dot wouldn’t be syntactically valid. So here we have the first major restriction: you can’t create new syntactic structures, you can only abuse the ones that are already there.
Now, I’ve had some reservations about the conceptual value of macros anyway, and this has firmed up my opinions. Macros are only useful if they’re relatively easy for the user to understand intuitively what they do. It’s interesting to look at Binsor here. For the most part it presents you with a view of the world that suggests the mapping from the DSL to Castle Windsor is simple. However, once you start digging under the hood, it gets unpredictable. To this day, I have no idea how to configure a facility; I’m using code ripped off the internet for each one. I remember it took me a day to figure out how to set a config value on a component. Ultimately, it’s a pretty big code base for something that can be 90% replaced with 5 lines in a blog post. (Not 100% yet, though. I’ll let you know when I’ve done that. 🙂 )
Obviously, all tools have advantages and disadvantages. But with Boo, I’m just not sure it’s got an advantage over IronPython I care about. I eventually ended up adopting pretty much the “with” code in the sample, because I don’t believe it can be usefully improved.
Technorati Tags: Boo,Binsor,DSLs