No DSL is 'human-readable' as such
One of the popular advantages attributed to using domain-specific languages is that they're 'human-readable'. This label is highly misleading because there is no such thing as a human readable computer language of any sort, DSL or otherwise.
Despite decades of AI research, we cannot instruct computers in natural language; it is too slippery and imprecise. As a result, all languages used to specify things to computers have specific semantics and are not simply 'plain English'. Even if you try hard to use English words and English phrases, what you wind up with is something like legal language (and for much the same reasons); the words may be English, but everything has a specific technical meaning and you cannot truly understand what programs actually do or write them until you understand those technical meanings.
(One of the heights of these attempts to be as English as possible is COBOL, and that didn't work; you still can't completely understand or write COBOL programs without knowing COBOL, and the process created an ugly monstrosity.)
DSLs are not magically exempt from this because they are small and simple (if they are). Just like other computer languages, you cannot really understand what any DSL 'program' does without learning the DSL itself, which is to say learning the specific technical meaning and semantics that the DSL attaches to words and phrases (and punctuation and so on). To the extent that a DSL looks 'human readable' without this learning, it's fooling you; you don't truly understand what things mean, and if you believe otherwise you can go horribly wrong.
(Sometimes you get away with it, just as much as you can sometimes hack away in a full programming language that is vaguely familiar to one that you already know. But that's not something to rely on; for real production work, as opposed to quick test hacks, you're going to need to learn the DSL.)
I believe that there are real advantages to DSLs, including being easier to read. But this is not the same thing as being 'human readable', and pretending it is distorts discussions of DSLs and their advantages (and drawbacks). Specifically, using a DSL instead of some alternative doesn't mean that people magically don't have to learn the DSL because they already understand what it does; they don't, not really.
(I alluded to this in passing in an earlier entry.)
|
|