DSLs in Boo

Ayende Rahien

Mentioned 3

Provides information on creating DSLs for Microsoft .NET using Boo.

More on Amazon.com

Mentioned in questions and answers.

I am trying to build a document assembly application in .Net that will allow rules and conditions to be embedded within the document fragments, presumably using some kind of scripting language (and I don't really want to invent my own scripting language)

I need the ability for the c# code to invoke the scripting language and vice versa, but importantly I also want them to be able to share arbitrary data structures by reference (not just passing a couple of strings back and forward by value)

Can I do this with powershell or do I need to use a DLR language such as IronPython? Come to that, are there other advantages of using a DLR language which mean I should use DLR anyway?


Powershell can instantiate and use C# (or any .NET) objects just fine. I've never tried having C# code invoke powershell commands, but I'd be surprised if it couldn't. That said, the DLR route is good too, and in fact there's examples in Ayende's DSL book http://www.amazon.com/DSLs-Boo-Domain-Specific-Languages/dp/1933988606/ref=sr_1_1?ie=UTF8&qid=1308063119&sr=8-1 that might be useful to you as well (even if you end up not using Boo, it's a good read).

I am looking for a good DSL Tool / Framework that meets the following criteria:

  • Can be used with / from C#
  • Runs on Windows Azure – the compiler can be generated anywhere, but the actual parsing takes place in the cloud
  • As fast and resource efficient as possible

I want users to be able to specify rules that are then interpreted by the program. The DSL is basically a subset of any scripting language - math operations, if-statements, string manipulation etc. - that works with domain objects (e.g. if (SomeComponent.Child3.SomeProperty > 3) SomethingElse.Color = Color(50,0,0)).
Since it will be users who create the rules, I think it would be a bad idea to use a real scripting language like IronPhyton (smells like SqlInjection, but worse) - also, I dont want users to actually program, so the syntax should be as simple and easy to understand as possible, thus a DSL.

The tools I stumpled upon till now are:

... plus many more I've read about here on SO but didn't look at yet in detail (like Oslo/MGrammar, Boo, Antlr...)

What exactly am I asking?
1. Which tools for creating a DSL in C# (or .NET) should I look at in detail, which do you suggest I should use?
2. Wich DSLs do you have experience with, what is your opinion? Is a certain technology cumbersome, slow, outdated, soon-to-be-replaced / cancelled? Let me know please.

In my constant strive to under promise and over deliver I'm looking to make a .Net tool to create simple .Net applications that the non-programmer superiors can use. How would I go about writing and compiling the code?

Explanation of intent: I want my superiors to, rather than ask me to make a barcode label app, select a few options, do a few test prints and then have the application created and ready to reuse. But how do I go about writing the output application for them to reuse on other machines?

Also, is this a terrible idea or have some merit?

Edit: To all those suggesting configurability over my original question: all the apps we release for internal use are being used by essentially day labor and my superiors prefer the applications to be static and unconfigurable. That being said, some of our apps haven't changed in 5 or 6 years because they were made to the specifications required. In the last few weeks they have requested 2 new barcode apps with a third requested in passing.

This is possible, although it is a lot of work.

I haven't tried this myself, but I'll told the easiest way to create such a application (technically knows as a "Domain Specific Language"), is to start with some dynamic language (such a IronPython or Boo) and build your language on top of it (Dynamic languages let you add new commands)

I friend of mine, who goes by the name of Ayende Rahien, even wrote a book about doing exactly that: "DSLs in Boo: Domain Specific Languages in .NET"