# Monday, 24 September 2007

jaoo2007_1 Domain specific languages (DSL) are gaining in popularity thus I wanted to know more about them and how I can go about creating them myself. Oren gave an interesting talk on that very topic. So what do we need a DSL for anyway? Oren's main point here was that a DSL will ease communication with the business because you get concise code that you can show to the business users who can then verify that the code actually does what they want. The DSL is basically syntactic sugar which makes everything clean and easy to read.

While I certainly get what Oren is saying I've yet to meet a business person who can actually relate to IT in a deep way much less to actual code however simple it may be. In my experience business persons shut down whenever things start to get hairy, seeing actual code is definitely the hairiest of disciplines if you ask me.

Two types of DSLs exist: External and internal. An external DSL is created from scratch, a couple of examples of external DSls are SQL and Regular Expressions. Of course a DSL created from scratch needs a lot of work to get going thus we arrive at internal DSLs. An internal DSL is actually piggybacking on an existing language which makes it easier to get going. Boo is an example of one such language well suited to creating internal DSLs though usually one would use a dynamic language for these purposes.

So what is Boo? Boo is a CLR language like C# and VB; it compiles to IL. What Boo provides over C# and VB is an open compiler architecture which provides you with access to the compiler at compile time allowing you to change the output. Interestingly Boo is white space significant; I didn't get the concept before Oren's talk but all it means is that indentation decides which code blocks belong together. For developing Boo code we have the open source IDE SharpDevelop which actually supports C# also. I heard about SharpDevelop on DotNetRocks! but didn't think too much of it as a product. Who needs an IDE which does less than Visual Studio? Well Oren showed us why SharpDevelop is a big deal for DSLs. Basically you take the code for SharpDevelop and create a version for your code-savvy business persons and have them develop their code in an environment tailored to their needs.

All in all an informative presentation given by Oren Eini. I wasn't convinced about the value of DSls when I left the session but talking with Søren Skovsbøll who had a nice example of where you can use a DSL very effectively: Namely for creating questionnaires. Questionnaires can be notoriously complex to put together with various rules and sub-questions depending on previous answers. It would simply be much easier to express your intent with code in say a DSL :)

As a little addendum I can mention that Oren actually started out by talking about fluent interfaces which are the simplest way of doing DSL-like stuff. What's interesting here is that fluent interface doesn't require you to learn a new language to implement. You can do them in you language of choice and gain a lot of expressiveness. Unfortunately the plumbing of fluent interfaces requires a lot of work which is why you usually go for a fullblown DSL instead.

Thursday, 27 September 2007 14:11:28 (Romance Daylight Time, UTC+02:00)
Thank you very much for posting this.
Eye opener for me in this direction.
peroth
Tuesday, 02 October 2007 07:53:05 (Romance Daylight Time, UTC+02:00)
"Who needs an IDE which does less than Visual Studio?"

That's a very funny statement ;)
With this outrageous attiude you risk of simply miss the objective view and might be incorrect.
Darius damalakas
Comments are closed.