Feeds

Making Java Groovy

It's Ruby, and then some

  • alert
  • submit to reddit

5 things you didn’t know about cloud backup

It is increasingly important to differentiate between Java the programming language and Java the platform.

While there have long been other languages that have targeted the platform, the best known being Jython – a version of the Python language that compiled down to Java byte code to be executed by the Java Virtual Machine (JVM) – recent moves have seen the emergence of "official" support for scripting languages (JavaScript, for example), JRuby, Sun's own JavaFX and more.

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

Groovy in actionVerdict: Highly recommended

Author: Dierk Koenig (with Andrew Glover, Paul King, Guillaume Laforge and Jon Skeet)

Publisher: Manning Publications

ISBN: 1-932394-84-2

Media: Book

List Price: £35.99

Buy this book at Register Books at Reg Developer's special discounted price. ®

Boost IT visibility and business value

More from The Register

next story
The Return of BSOD: Does ANYONE trust Microsoft patches?
Sysadmins, you're either fighting fires or seen as incompetents now
Linux turns 23 and Linus Torvalds celebrates as only he can
No, not with swearing, but by controlling the release cycle
China hopes home-grown OS will oust Microsoft
Doesn't much like Apple or Google, either
Sin COS to tan Windows? Chinese operating system to debut in autumn – report
Development alliance working on desktop, mobe software
Apple promises to lift Curse of the Drained iPhone 5 Battery
Have you tried turning it off and...? Never mind, here's a replacement
Eat up Martha! Microsoft slings handwriting recog into OneNote on Android
Freehand input on non-Windows kit for the first time
Linux kernel devs made to finger their dongles before contributing code
Two-factor auth enabled for Kernel.org repositories
This is how I set about making a fortune with my own startup
Would you leave your well-paid job to chase your dream?
prev story

Whitepapers

Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Endpoint data privacy in the cloud is easier than you think
Innovations in encryption and storage resolve issues of data privacy and key requirements for companies to look for in a solution.
Scale data protection with your virtual environment
To scale at the rate of virtualization growth, data protection solutions need to adopt new capabilities and simplify current features.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?