Making Java Groovy
It's Ruby, and then some
It is increasingly important to differentiate between Java the programming language and Java the platform.
From being a single language, multi-OS environment, the Java platform is increasingly both multi-language and multi-OS. And in this new eco-system the Groovy language seems to be thriving nicely.
Groovy is, to quote from its home page, "an agile dynamic language for the Java Platform". What this means in practice is explained in some detail by Groovy In Action, a big book in every sense of the word. It begins with the assumption that the reader is familiar with both the Java language and the platform, and from there proceeds to explore the new world of Groovy programming.
Groovy offers many of the benefits claimed for Ruby – higher levels of abstraction, concision, less boiler-plate code, closures, mixins, elements of functional programming, dynamic programming features, and so on.
However, unlike Ruby, Groovy has a syntax and a structure that is immediately obvious to a Java programmer. Furthermore, it enables mixed programming – it can make full use of existing Java classes and packages, (including the full set of standard Java libraries), and Java code can (mostly) make full use of Groovy classes in turn.
The first part of the book explores the Groovy language, doing a good job of showing the reader all of the gee-whiz features that make it different to Java. The point is that this isn't just Java with fewer key-strokes (though it's certainly possible to use it that way). Groovy's support of closures, for example, is intuitive and powerful and offers a facility that plain old Java is currently lacking.
Having successfully toured the language, the second part of the book dives into the Groovy libraries, in particular Builders, database programming, XML, integration, and the GDK. As with Java there's a lot more to Groovy than just the syntax and program structure, the libraries provide high-levels of functionality to address common programming problems.
The final part of the book looks at Groovy in action day-to-day, from opening up the Ant build tool, to unit testing, COM integration under Windows, and introducing the Grails framework. In the same way that Rails was the lure to Ruby for many programmers, the Grails web application framework is enticing developers to take a look at what Groovy has to offer.
Aside from the intrinsic interest in the subject matter, it has to be said that this is a book that is very readable, engaging, and does a great job of slotting Groovy into the broader world of software development.
Of course, it asks provocative questions as well as answering them. For example, there's a huge clamour to add closures to the Java language at the moment (as part of Java 7). With Groovy around this reader at least wonders why anyone would want to complicate the core Java language yet again?
Groovy in Action
Verdict: Highly recommended
Author: Dierk Koenig (with Andrew Glover, Paul King, Guillaume Laforge and Jon Skeet)
Publisher: Manning Publications
List Price: £35.99
Buy this book at Register Books at Reg Developer's special discounted price. ®
Sponsored: Customer Identity and Access Management