Domain Specific Languages (DSLs) – In General and How PowerShell Relates

PowerShell Team

While attending JAOO, I had the great pleasure to meet and talk with Martin Fowler and Neil Ford on the topic of Domain Specific Languages (DSLs).  Channel 9 videotaped that discussion and you can watch it HERE.

I’m quite passionate about DSLs – both FOR them and AGAINST them.  The details matter!

I have this concept called, “Beer Cardinality” and it applies to DSLs.  Here is the way it works:

Have no beers  => Yawn!
Have 1 beers    => What’s the point?
Have 2-6 beers => Happy Happy!
Have 24 beers  => Vomiting, hangovers, regret regret regret

DSLs are awesome BUT if you have too many, it can lead to a nightmare.  Let me draw a distinction and be more precise – there are SYNTAXes and there are VOCABULARIES.  It is fine to have a zillion Domain Specific Vocabularies (DSVs) but you only want small set of Domain Specific Syntaxes. 

There is also a very interesting discussion around Internal vs External DSLs.  Internal DSLs are essentially DSVs for particular languages Javascript, C#, PowerShell etc.  External DSL are distinct, self-contained elements orthogonal to the engine and language used to implement the engine (which processes the DSL artifact).  The problem is that you want BOTH.  You want the syntax of an Internal DSL so you don’t have to learn a set of skills which put your resume into the bit bucket.  You also want an external DSL so that you can create artifacts with a well define scope of effect to facilitate transferability of the artifact.  Consider these 2 cases: 

1) I give you a 20,000 line file written as an external DSL and that DSL can do exactly one thing – it can generate Strings. 
2) I give you a 20,000 line file that is Java, C#, JavaScript,etc and I tell you all that it does is to generate strings. 

Now I say, you have to run that on your production server.  Consider what level of QA you have to do in the 2 cases.  In case 1 – you KNOW with metaphysical certitude that the DSL can ONLY generate strings.   In case 2 – it can do anything but is optimized for generating strings.

See my point?

So what you want is both internal and external DSL.  Hmmmmmm, that would explain why we have the DATA segment as part of PowerShell V2.  This gives you the best of both internal and external DSLs.  Notice that in our DATA segments, you can specify -SUPPORTEDCOMMANDS – this gives you the ability to specify a DSV.   Yummmmmm! 

People have no idea of the power and flexibility that they are going to get with PowerShell V2.  It is going to be awesome!

 BTW – I went to Martin and Neil’s talks and they are super smart guys and I highly recommend going to any talk they give.  Great stuff.  Truly enjoyable.  I didn’t agree with it all (as you’ll see from the interview) but it was all worth listening to.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at:


Discussion is closed.

Feedback usabilla icon