by Venkat Subramaniam
As I discussed earlier this year, Groovy is an excellent language for scripting on the JVM. It's also excellent for writing large programs that go well beyond what we call scripting. The release of Groovy 2.0 late last year brought considerable new magic to an already useful language. The big problem, as I explained, is that documentation of the new features has been slow to come to market.
This new edition of Subramanian's earlier book on Groovy does a very good job in filling the need for a usable tutorial. Its approach is to dedicate one chapter to each feature that truly distinguishes Groovy. In those chapters, Subramanian's ease with explaining difficult topics is very much in view even discussions of AST transformations and compile-time metaprogramming are easily approachable. (Subramanian's earlier book with Andy Hunt, Practices of an Agile Developer, won the 2007 Jolt Award. So, he's been a good writer for a while.)
While I can recommend the book, it has some weaknesses to note. Subramanian's approach to all explanations is to present the code as scripts. As a result, there is no
main() function presented anywhere, nor discussion of assembling and building large programs from all Groovy code. My second complaint is that the unusual ordering of the chapters a problem in the first edition has been carried forward to this edition. After two initial chapters on background info (installation and IDE options, then the differences between Java and Groovy), the third chapter dives into Groovy's complex optional typing, its implementation, and related esoteric topics such as multimethods. All this before the reader has looked at anything more than tiny snippets that compare Groovy code with Java. A reader new to JVM languages would be completely lost.
For seasoned developers, the latter gripe won't matter terribly. But even experienced developers will be forced to address the first complaint by looking up the material elsewhere which is not what you want when reading a language tutorial.
In sum, this book is the best Groovy 2.0 title available at present; it's well written and very clear, and should be the first choice for developers interested in Groovy despite its limitations. For Groovy developers, it's a must-buy update.