Wednesday, August 5, 2009

DSL Killer Application

Now I want to point at a really mind-blowing tool called JetBrains Meta Programming System. You see, some time ago to implement your own Domain-Specific Language it was necessary to develop a grammar, implement a parser (or use such tools as GNU Bison for example) which normally operates in XML SAX manner and finally do something with the results obtained. Nowadays these new tools enable you to do virtually all this stuff in kinda type-safe way. It strictly watches at all your manipulations and alerts violations.

The whole process somehow resembles XDoclet and XSLT a bit, but it's much more reliable, because of the advanced IDEA editor, which takes into account all the necessary constraints, disallowing to misprint something. Still (due to verbose syntax) logical errors at source generation stage are highly possible. Good news is that you can use the whole power of modularity in this process to reduce such risks. Maybe the most striking thing about it is that its own language to define grammar and generate artifacts is also a DSL implemented in the same environment!

You can download JetBrains MPS here for free and try a tutorial. It will take some time to get used to the tool's UI. Its strangeness is in fact that there's a pretty complex tree representation behind a text you see on the screen, and it contains a lot of meta-information displayed as special markup signs, different colors, etc. So you shouldn't think of it as of a plain old source code anymore (to see what I'm talking about, just look at XML files inside a simple test project).

There are some alternatives to this environment, namely Microsoft Visual Studio Domain-Specific Language Tools and MetaEdit+, though I haven't tried any.

P.S.: Thanks to Martin Fowler's bliki for the link - it's a really visionary source of information! Here you can also watch his video on this topic.

No comments:

Post a Comment