Wednesday, March 26, 2008

Domain specific language - Primer

Perhaps you may have seen this term in VS2008 when it loads up on the start screen or perhaps you have seen it in some academic course of study, or perhaps you have no idea what it is!! Well this short post will hopefully give you some answers to what it is, why you need it and how to get started using it.


What is it?
Well firstly it is not a GPL, a general purpose language like VB.NET,C# or any other programming language that lets you code using a specific language to suite a diverse set of tasks. It’s actually the other way round, it’s useful for a specific task to fix a problem within that domain. Using it allows you to build a modeling tool or define a modeling language for that task. It also makes implementing the solution to that problem a lot easier, however it does shift a lot of the work up front. i.e developing the tool is hard work, but once it’s built it’s a lot easier to solve problems using it!!! Domain-specific languages focus on doing one kind of task well. It’s kinda like UML, but without the U. http://en.wikipedia.org/wiki/Domain-specific_programming_language


What can you do with it?
For example, you can create a specialized language that describes a user interface, a business process, a database, or the flow of information, and then you can generate code from those descriptions. The DSL does not have to fit just IT or programming tasks, you may wish to model other things like solar systems. By using Domain-Specific Language Tools, you can create a custom graphical designer that uses your Domain-specific diagram notation. You can then create custom text templates that use models that are created in your designer to generate source code and other files.
What tools are there out there?

What does the VS2008 DSL tool consist of ?
· A project wizard that creates a fully configured solution. In this solution, you can define a domain model that consists of a designer and a text output generator. If you run a completed solution from inside Visual Studio, a test solution opens in a separate instance of Visual Studio so that you can test the designer and the text output generator.

· A graphical designer for defining and editing domain models.

· Designer definitions in XML. The code for implementing designers is generated from these definitions so that you can define a graphical designer hosted in Visual Studio without manually writing any code.

· A set of code generators, which take a domain model definition and a designer definition as input and produce code that implements both of the components as output. The code generators also validate the domain model and the designer definition, and they raise errors and warnings accordingly.
· A framework for defining text output generators. These template-based generators take data (models) that use a domain model as input and generate text output that is based on the template. Parameters in the template are substituted by using the results of running a Visual C# script that is embedded in the template.


What VS editions support DSL
For creating a DSL you will need any of the following:
· Visual Studio 2008 Professional Edition
· Visual Studio 2008 Team Edition for Software Architects
· Visual Studio 2008 Team Edition for Software Developers
· Visual Studio 2008 Team Edition for Software Testers
· Visual Studio 2008 Team Suite

In order to use the DSL you create you will need on of the following VS IDE’s@
· Visual Studio 2008 Standard Edition
· Visual Studio 2008 Professional Edition
· Visual Studio 2008 Team Edition for Software Architects
· Visual Studio 2008 Team Edition for Software Developers
· Visual Studio 2008 Team Edition for Software Testers
· Visual Studio 2008 Team Suite

OK so not much choice, you can’t use VS2005 or 2003 I’m afraid.

OK enough already! How do I create a DSL? That will be the topic of my next post!!

No comments: