Book Review: Programming Groovy
Programming Groovy is a great starting point to the Groovy language and more so if you are already decently acquainted with Java . The whole book is divided into three parts, each part looking at different features of the language.
Part I: Beginning Groovy
As the name of this part suggests, in this part of the book, the author begins with instructions on how to go about setting up your system for Groovy development. Among other things, working with the Groovy shell is demonstrated.
Being well acquainted with Java, I skimmed over the chapters 2 and 3. Things are very familiar in these chapters. Chapter 4- Dynamic Typing talks about data types in Groovy and some other essential information of typing in Java world and its counterpart in the Groovy world. This chapter also introduces multi-methods. Chapter 5- Using Closures was the first major interesting roadblock for me. I intended to understand it fully and so I read this chapter and worked on it for a couple of times. Co-incidentally, I was also reading about closures in Common Lisp. You will need to understand at-least, what closures are and how they can be used- Sections 5.1-5.3 (as you will later see) that closures are widely used in Groovy. Most of the times, you will be passing a closure around to standard method calls in Groovy. So, understanding how a closure works is very useful. You may also want to read more about closures here. Chapter 6- Working with Strings, introduces the GString ( he he )- which are interpolated strings, and also talks a bit about the GString Lazy Evaluation Problem. Some other topics include: Groovy’s own String Convenience Methods, and Multiline Strings. The last chapter in this part- Working with Collections talks about working with the usually available data structures: lists, maps and arrays, alongwith the convenience methods made available by Groovy.
Part I is over and I haven’t yet learnt to take a User Input or is it assumed that I am a Java developer?
Part II: Using Groovy
Using Chapter 8: Exploring the GDK, looks at the extensions provided by the GDK to make the JDK more groovy.
In the next three chapters, the author will help you start using Groovy in your daily tasks, like Working with XML files, Databases (GSQL) and mixing and matching Groovy and Java.
Part III: MOPping Groovy
This part of the book looks at the implementation of the Meta-Object Protocol in Groovy and essentially builds upon it to present other very useful concepts such as Unit Testing and Mocking (where you are shown how to write Unit tests for your Java classes in Groovy), Groovy Builders and finally, at Creating DSLs in Groovy. This part can be classified as some serious and advanced Groovy and is a great collection of some very cool concepts in Groovy.
Overall, this book of is a great introduction to Groovy for the Java developer. I am not sure, how non-Java developer would benefit at all from this book, or for that matter Groovy.
Great work by the author and the whole team!
To learn more about the book, errata and discussions, please go to http://www.pragprog.com/titles/vslg/programming-groovy
Many thanks to O’Reilly UG program for providing with a review copy to BOJUG. This review is also published at the BOJUG blog at http://bojug.in/blog/?p=49