I had almost made up my mind that the speaker was going to make the speech
too exotic by spewing jargon. To my surprise, the talk was kept quite on the ground.
For the un-initiated, the presentation must have been fantastic the way the tempo
was built up. Unfortunately, for the ones having some experience in implementing
DSL the talk was too lullaby like. I craved for a more involved discussion on the
topic.
There was an interesting question posed by one of the participants about the opposing
forces the speaker had to deal with while zeroing on the need to create a custom
language instead of using an off-the-shelf rule language. From the discussion it
became evident that the decision was driven primarily due to the unavailability of
off-the-shelf rule engines in the implementation language domain. A justifiable
reason, but I hoped for the speaker to shine some light on the forces surrounding
the need to incorporate DSLs, in general.
I have been experimenting with DSLs for some time now. From my sphere of experience,
DSLs have proven quite useful from an end user's perspective for complicated
configuration needs. For higher order logic externalization, rule engines are
almost always a better fit, evaluating the implementation complexity, knowledge
curve and proprietariness of the solution.
One of my engagements dealt with
service orchestration at a micro level. Services were quantum of activities
written as pluggable classes, which could be declaratively wired into an
orchestration structure as shown on the image on the left. Initially we started
off with the idea of specifying the branching configuration via XML files, but
soon realized that from a end user's perspective it became way too convoluted to
manage the configurations. A much more intuitive mechanism was required to specify
the configuration. The expression on the bottom of the image was found to be most
suited for expressing such a branching structure. This form of configuration was
much more comprehensible from it's XML equivalent.
The following BNF grammar was developed to implement the custom configuration
language:
1. expression = expr "," expr | expr
2. expr = term "|" term | term
3. term = "(" expression ")" ["*"] | IDENTIFIER ["*"]
This was one of the typical DSL implementation scenarios where the cost of using
a rule engine was too much of an overkill. The grammar was also way too simplistic
to warrant the need of parser generators like ANTLR etc. However, irrespective of
the way the parser was implemented, it was noticed that a significant amount of
logic was required for the processing of the parse tree and translating it into
its working equivalent. This effort would have been required irrespective of
the choice of implementing the configuration interpretation, whether it was
expressed in XML or custom language. This was done couple of years back. Today
there are quite a number of DSL workbenches which claim to make life much
easier. Microsoft has launched an elaborate DSL workbench. I am yet to explore
these new tools on the block.
These are some brilliant articles by Martin Fowler on DSL.
Language Workbench - killer apps for DSL?
Domain Specific Languages
|