Thursday, May 08, 2008

JavaOne: The power of Groovy Builders

I attended two talks on Groovy Builders yesterday that clearly illustrated this power feature of the Groovy language.


The basics on builders was covered in a late night BOF "Cooking Your Own Groovy Builder: A Step Forward into Domain-Specific Languages" given by Andres Almiray and Ixchel Ruiz. They reviewed builders for Swing, Java2D and the generic ObjectGraphBuilder which help to take a significant amount of toil out of working with Swing, Java2D, or creating generic object graphs for testing. Builders are also used for creating HTML or XML documents using syntax like:



html { head { title "My HTML Document" } body { h1 "Hello World p "Isn't this nice?"} }

That's a useful way to express structure using a syntax that is essentially added to the language by implementing a Builder. Builders are not limited to just generating code or data. In "Groovy on a Cloud: Testing Java™ Platform, Enterprise Edition (Java EE Platform) Applications on Amazon EC2", Chris Richardson showed how he created a domain specific language, using Builders, which can be used to provision Amazon EC2 instances by describing them in the DSL. The technique is described in a blog post. Really impressive stuff.




Labels: , ,

Wednesday, May 07, 2008

JavaOne: Great Turnout for Groovy/Grails Talks

I'm really happy to see a big interest in Groovy and Grails this year at JavaOne. Last night I attended Guillaume Laforge's "Grails in Depth" talk and today I sat in on Scott Davis', "Groovy, the Red Pill: Metaprogramming--How to Blow the Mind of Developers on the Java™ Platform" session. Each of these sessions were packed so hopefully that means the already large community around these technologies will continue to grow.


I've been using Groovy and Grails for a long time now and have developed several production programs as well as a reporting application linked to Basecamp. I love the language and this web development framework. It is an interesting contrast to JRuby and Jython in that there seems to be much less cognitive context switching when using Groovy. One can write Java (quite literally) in Groovy and slowly make the migration of programming style to a more Groovy sensibility when you are ready. Not the case if you are using JRuby or Jython. Not that there is anything wrong with these languages, I use Python almost daily, but shifting to a dynamic language from Java has to be easier if you decide to start with Groovy.


It's a great time to get involved in dynamic languages on the Java platform. There is so much choice and power available.



Labels: , ,