Monday, January 26, 2009
Playing with Domain Specific Languages in Groovy and Grails
The whole idea is related to the possibility of adopting multiple DSL simultaneously. I took some interesting hints from Guillaume Laforge, Graeme Rocher and Peter Backlund, for the DSL part, as well as some from Ninja Coding Monkey, when it came to integrate my DSL specific value Objects with Grails.
Groovy meta-programming offers tools for designing DSLs that were not possible in a static language such as Java. Operators overloading and coercition make it smooth to deal with numeric types including non-primitive types such as BigDecimal or BigInteger. Still, the most powerful tool is the possibility to re-define the reference operator ‘.’
allowing for more compact and explicit notation such as
100.EUR == 50.EUR * 2
for Money types.
However, this involves adding new behavior on the Number metaClass, which is not entirely correct in terms of object oriented responsibility assignment: it’s basically a new Money constructor that we’re attaching on the Number class instead. It works, it’s cool, but it’s definitely not the cleanest code on Earth.
Different DSLs have many points in common and their readability relies heavily on the same features, so a centralized coordination role turns out to be necessary. At the moment I am working on a prioritized DSL engine that allows pluggable fine-grained DSL to be activated separately in the same application, for example I can write something like:
1000000.EUR == 1000.k.EUR
1000.k.EUR == 1.M.EUR
but that’s only a small a part of the fun. More details in the next posts
Tuesday, November 11, 2008
Wednesday, April 16, 2008
Italian Grails User Group Started
http://it.groups.yahoo.com/group/Grails-IT/
Everyone interested is warmly welcome! (ma si parlerĂ in italiano...)
Monday, December 10, 2007
Back from the Rome Java Day 2007
… So I am back also from the Java Day, in Rome. It was my first time ever, there. And I was also a speaker (and obviously I was late with my slides…) so I feel like I missed quite a big part of it.
I followed Luca Garulli's presentation about the Roma Framework, which in some ways is a competitor of Grails (the subject of my speech) . Roma has some interesting features, like the built-in user profiling module, and a fancy Echo2 based web interface.
Even if I was dead hungry when I had my speech, I manage not to think about the food and to keep the speech reasonably enjoyable. Anyway, Grails is such an effective tool and full of good ideas that, even in a 10 minutes demo, the audience caught the tools potential, and getting to the end was a piece of cake.
This was one of the closing event, after that we went eating out with all the staff end the speakers in a typical restaurant nearby, and had some good time together. This made the perfect ending for a nice day: despite being a free event and basically based on volunteers the result was absolutely good (thanks to Mara and all the staff that made a hell of a job), with more than 1000 attendees this year.
By the way, presentations slides are already online, and mine can be downloaded here
Friday, November 09, 2007
Upcoming Events: Java Day 2007 in Rome
I'll be one of the speakers, talking about Grails
I've checked the official program of the day. And I'll be speaking around lunchtime. This is bad, because at that time I'll be incredibly hungry, and being hungry is the only thing that gets me angrier than bad code... At the last java conference in Milan I remember finishing late the morning session, and being the first afternoon session. So I had to skip lunch, really wanted my speech to and as soon as possible, just to have a pizza, a sandwich, or ... whatever. I'll be prepared this time.