Groovy & Grails

This evening I went to the Groovy & Grails User Group meeting, held at Skills Matter in London.

The first presentation was

Grails and Hibernate

by Graeme Rocher (project lead of Grails, and new CTO of Skills Matter).

Graeme gave some background on Groovy and Grails, and then showed some examples of the domain model layer in Grails and how dynamic finders can be used. As someone who knows Rails, it seemed quite familiar, although an extra feature Grails had was criteria based finders. (There may be a plugin for this for Rails, I’m not sure).

Anyway, back to the start. Groovy is a scripting language for the Java platform, taking inspiration and features from languages like Ruby and Python. The difference is that it has been designed from the start to integrate with Java very closely, so Groovy compiles into bytecode, and a Groovy class is interchangeable with a Java class (given the runtime support library).

Groovy supports closures and other dynamic features that make for more expressive coding, but it also allows a mixture of static typing and dynamic typing, so in some ways it can get the best of both worlds.

Grails is a web application framework inspired by Ruby on Rails, but built using Groovy and Java. Rather than develop a whole new framework, Grails makes use of the popular Spring and Hibernate frameworks – but introduces Rails’ ideas of ‘DRY’ and ‘configuration by convention’.

Grails is in early versions at the moment, but could be a useful way of building web applications more easily while retaining the benefits of the Java platform. (I guess in a way it is competing with JRuby on Rails – it will be interesting to see how the two develop).

The second presentation was

AntBuilder and Gant

by Russel Winder (It’z Interactive).

Russel explained why he is known as ‘build guy’ on the Groovy mailing list, starting with a brief history of build tools. The only ones I had heard of were Make and Rake. He pointed out that Ant and Maven, the two main build tools used in the Java world, both use horrible XML syntaxes. XML is good for data exchange, but not for writing tool scripts.

AntBuilder is a simple conversion which allows you to write Ant scripts in Groovy, using the Builder concept. This uses closures for structure by nesting them inside each other, while the context of each closure is a special object, AntBuilder in this case, which understands what to do with any functions in the script that aren’t actual declared functions. (It’s easier to use it than explain it).

AntBuilder scripts don’t look that different from XML Ant scripts, other than the syntax change, but Gant was a bit different. It seems more like a new build tool, except it still uses Ant tasks underneath for easy portability. I’m afraid to say that I didn’t really understand the difference though. The first public version has only just been released, so maybe I’ll have a look.

It was interesting for me to get this chance to catch up on the Groovy world – last time I looked, the Grails project was just starting to be discussed, so it was good to see that it is up and running now.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*