Thursday, December 8, 2011

The Art of Groovy Command Expressions in DSLs

Domain Specific Languages (DSLs) are often littered with the accidental complexity of the host language. Have you ever seen a supposedly “friendly” language expression like “ride(minutes(10)).on(bus).towards(Basel)”. The newest version of Groovy contains a language feature that aims to eliminate the noise of all those extra periods and parenthesis, so that your DSL looks more like “ride 10.minutes on bus towards Basel”. This article shows you step-by-step how to use Groovy Command Expressions and plain old metaprogramming to write just this DSL, and also offers advice on when, and when not, to use this new language feature.

The full article is available over on the Canoo Blog: http://www.canoo.com/blog/2011/12/08/the-art-of-groovy-command-expressions-in-dsls/

And of course you can upvote in all the usual places.

Until next time...

3 comments:

greg said...

Damn you Hamlet ! Just yesterday I was desperately searching for a decent article of this nature. Now you went ahead and WROTE IT ? Are you reading my mind ? Are you following me ?

Hamlet D'Arcy said...

Actually... you might be following me. The article originally appeared in No Fluff Just Stuff magazine about 4 months ago. But now the copyright is MINE ALL MINE.

shyn hye park said...

very interesting article, my information is concerned.
Loola 2