Archive for the ‘domain specific languages’ Category

A language for defining Domain Specific Languages

June 26, 2009

I’m a bad boy. I promised to post about domain specific languages. It’s been three weeks since I posted anything at all. But it doesn’t mean that I’ve been doing nothing.

I’ve been designing a language for defining Domain Specific Languages. A Meta DSL. And I made it my first source forge project ever. It uses groovy, so I looked for a name starting with “gr”. “Grunge” was still available as a project name on source forge. So I decided to call it that. It only gives you a basic idea, but I intend to extend it.

At my office, my colleague and I did our first automated build on Bamboo of a grails project. Turned out to be very easy. You just tell Bamboo about the build.xml file generated by grails, and it will do all the work for you. Including downloading dependencies from ivy.xml. It just did not work out of the box for grails 1.1.1. Instead of finding out why, we decided to use grails 1.1 for now.

And in the meantime, my ebook reader arrived, so I did lots of reading. I ordered Unlocking Android. So you might expect some posts on that. But I’m not promising anything anymore.


DSLs: tweaking your language into something else

May 26, 2009

I found myself a new subject to dive into. There’s nothing like tweaking a programming language the way you want it. Adding your own constructs to your programming language, making it more expressive. Coding is all about expressing your intent as clearly as possible. So why stick to the plain old language constructs that others created for you? If you’re specifying calculations for an insurance company, why not use the abstractions and expressions that your customer knows? Wouldn’t that make communication with your customer easier? Of course, the actual calculations will be written in plain old straightforward code. But wouldn’t it be nice to have a thin layer on top of it, allowing you to express domain specific knowledge a bit more like natural language?

Such a thin layer is called a Domain Specific Language (DSL). Martin Fowler is writing an excellent book on the subject and he describes three kinds of DSLs:

  • internal DSL’s, that build on top of an existing programming language
  • external DSL’s, that have their own parser
  • language modelling frameworks, that have a user friendly click and paste GUI

As you might have guessed, I’m especially interested in the first one. Groovy has excellent support for it. And in Lisp – though its syntax sucks – it is very common to create your own domain specific commands. Actually, studying some Lisp last year got me started in “language tweaking” in the first place. But also in Java you can do some things.

There are a number of grammatical constructs you can use in a DSL. Most of them can be implemented in Groovy. Some of them can be implemented in Java. So what I’ll do the coming weeks, is explore each of the grammatical constructs and compare them in Groovy and Java. First one coming up soon.