I’ve been bothered for a while with the overuse of the term “Domain Specific Languages”. While I really like the stuff that I do via metaprogramming in Ruby, what I do isn’t a true domain specific language.
Just now, I see that Martin Fowler had coined the term Internal DSL to describe what I tend to do. I like it more than DSLs since it makes it clear that the DSL is embedded within the host language. It’s well worth reading the entire article if you’re interested in this area.
2 archived reader comments
Charles Oliver nutter (2006/05/10)
So you dislike the overuse of DSL, eh? :) I agree the internal vs external distinction is a good one. The DSL you and I have both been using (and really, the whole "builder" DSL model being used and abused heavily by numerous Ruby apps) would obviously qualify as an internal DSL. Increased specificity is certainly a good thing. I also like the instance_eval trick to avoid the block param…that may come in handy to further simplify the code generator. My only concern would be that the blocks lose some of their usual semantics; namely, inner blocks can no longer access variables from containing blocks. Now naturally we want to restric each level of the DSL, but it complicates housing the core utility methods that may be necessary to call a any time. Currently they reside on MethodBuilder, used at the method level. However, during ParamBuilder-ing, it may frequently be necessary to call those core utility methods. At any rate it would be easy to change later…it may turn out that the restriction is valid and useful, or that its detriments are outweighed by the simplified syntax. Given that this is intended to be a general-purpose bytecode generator, any simplification would be helpful.
John Lam (2006/05/11)
I found that specifying method names + signatures as strings gave me a lot of flexibility. I was going to lock things down more but never got around to it, and am thankful that I didn’t :)