My latest and last (for the moment anyway) article for MSDN just went up today. This time I tackled the design patterns and strategies for building Internal Domain Specific Languages. At least in the .Net space, the mainstream folks seem to hear “DSL” and only think about big efforts to create business facing languages with external DSL tools like Oslo — probably because that’s been their first exposure to the idea of DSL’s. That stuff is valuable in places, but don’t overlook the value in creating small mini-languages inside your everyday programming language for developer related tasks.
Mini-language or Internal DSL‘s may be a misnomer in this case. All you’re really attempting to do is to create a more usable form of API that ends up being more readable and quicker to specify than the standard “push button” API. You see more and more examples of these little internal DSL’s in open source tools like Fluent NHibernate, StructureMap, Windsor, and AutoMapper. Now even Microsoft is dabbling in mini-languages with the “Code Only” configuration option in Entity Framework 4 (which at a glance seems determined to replicate every single mistake that Fluent NHibernate made early on).
I’d hoped to include much more writing on this topic in my blog, but I’m a bit burnt out at the moment. At some point in the next month I’d like to write up my lessons learned with the StructureMap Registry DSL and how it’s evolved over the past three years to improve its usability, the problems users have had, dumping the “English like” syntax in favor of something terser, and how I build the DSL stuff. Also, I’d like to explain the “Object Scoping” pattern that got cut from this article. Lastly, I’ve got a little Internal DSL we use at Dovetail for user action routing that I think would make a good, approachable example. I’m on a bit of a New Year’s Resolution to spit out more (any) blog content.
Lastly, I’d like to write up a retrospective on the whole Patterns in Practice column I’ve been writing for the past two years.
The pattern names for the article and much, much more information were drawn from Martin Fowler’s online draft for his DSL book at http://martinfowler.com/dslwip/. I’d heartily recommend perusing the site if you’re interested in DSL development at all.