Domain Specific Languages

A recent post by occasional and well-read blogger Steve Yeggi got me thinking once again on the subject of Domain Specific Languages, or DSL for short. The term was coined a couple of years ago and refers to creating your own language for a specific purpose relevant to your application. Together with the language you need to program the parser and processor for it. For example there have been countless form generators which takes some kind of structured text file (XML?) as input and generate a form. Another more down to earth example is to take a write a program that takes CSV file with addresses and use it to fill a database.

Using a DSL is a good and powerful way to create code abstractions. So use them where they seem fit. There is a downside, DSL are by their very nature Domain Specific and suffer from the greatest problem of all domain specific code, the “not-invented-here” syndrome. DSL’s will be reengineered and refactored away in most cases before the program life ends. Either because somebody does not understand the DSL (which is a bad thing) or because the DSL obsoleted by generally available languages or frameworks. In the latter case refactoring is the way to go. For example many configuration DSL’s in Java programs have been obsoleted by the Spring framework.

As a side note the post from Steve mentioned the classical Compilers book as the background in creating DSL processors. Nice time to take it from the shelf and browse through it. Another 10 years and it will cost $1000.

Advertisements

%d bloggers like this: