views:

115

answers:

2

I'm just learning about DSLs and I'm trying to put them in a context I can understand.

Let's say we're talking about internet advertising, for example - since that's a field I would like to work in - what's an example of a small custom DSL you might build?

Also, what are some of the high level technical steps you would need to implement this?

A: 

Domain specific languages are, by definition, a language designed for use by the domain experts.

The topic is quite large, and can be segmented by:

  • internal or external - is it part of a host language which programmers write, or standalone.
  • imperative or declarative - do you dictate the flow of a "program", or are you writing down properties that need be fulfilled.
  • audience - is this to be written by programmers or non-programmers

A large subset of DSLs (including the one below) can be described as rules which are evaluated all at once by a rules or inference engine.

For the domain of internet advertising, you may want to come up with a set of business rules which govern which ads are shown on a given page.

if page.popularity is high then use ads of account[valuable]

if page.topic is not NSFW then use ads of topic[not NSFW]

if browser does not support flash then use ads of capability[javascript]

In this particular case, a clean, popular page would get the ads from the best paying account, and safe for work.

If this is an approach which has resonance for you, you may want to integrate an existing Rules Engine. This is particularly sage if the end-users are not developers, as you will need to provide a certain amount of tooling as well as the DSL.

jamesh
+1  A: 

I have been using DSL Tools for VS2005 for the last year.

In order to learn it, you ought to read "Domain-Specific Development with Visual Studio DSL Tools" by Steve Cook, Gareth Jones, Stuart Kent and Alan Cameron Wills.

This should be your entry point and it covers every aspect about the technology including some advanced topics.

Luis Filipe