M. Edward (Ed) Borasky said:
Well ... there are two reasons to write a Domain Specific Language:
1. As a way of organizing your own programming, and
2. As a tool to be used by *others* to perform a job.
For 1, I think any way of doing things that organizes your code for
yourself and your team/enterprise that works is in some sense the
"right" way, whether that be functional, object-oriented, or even
spaghetti code.
But for 2, I'm not at all convinced by the DSLs I've
seen over the years, including those I've written myself. People in
general aren't programmers, and designing a programming language for
them may not in fact lead to increases in *their* productivity.
I'm glad you enjoyed the trip down memory lane ;-). I gave up on
functional programming over a dozen years ago, for two reasons: first, I
learned the hard way that writing really good compilers for lambda-based
languages requires a huge amount of mathematical knowledge, and mine
doesn't go beyond partial diffeqs. Second, my experiments with ordinary
professional programmers proved that the proportion of them who are
mentally receptive to the functional style is too small to be
commercially valuable. I was completely taken with FP myself, but one
programmer does not a team make.
To your point about regexes: remember that they are level-0 languages,
whereas most programming languages (including useful DSLs) are level-1
languages (context-free grammars). AFAIK, a language that generates
expressions that can be reduced to NFAs can not be Turing-complete, but
correct me if I'm wrong on that.
A poorly-designed DSL is just as useless as any other tool that doesn't
reflect an appropriate modeling of the problem domain (not too powerful,
not too trivial, but just right). Still, I think it's pretty exciting
that Ruby makes DSLs easy and graceful, thus activating for imperative
programmers one of the most useful aspects of Lisp. (I'm sure that
statement will be hotly contested by Lisp partisans, but let them rant.)
With DSLs, I'm thinking about tools for programmers, not for
non-programmers. (Although there is a very interesting class of
highly-successful mini-languages for non-programmers, like MS Office
macros.) My point about "tooling" was in regard to automatic programs
that can reason about other programs. DSLs and other mini-languages are
far easier to write workbenches and IDEs for, which I think is really
interesting and potentially a huge productivity boost. And again, it's
the reduction from full Turing-completeness that may be the secret
sauce. I wish I could prove that, but I've already told you that I'm no
mathematician, so it's a hunch at best.