Saturday, June 28, 2008

Book Review: Groovy Recipes

I just finished reading Groovy Recipes book by Scott Davis so I would like to share my opinion about the book. Book is excellent "I'am in a Hurry" guide and you can get initial, but good enough knowledge about Groovy in a really short time. For sure it is not comprehensive guide to Groovy.

If you are Java developer and want to jump on Groovy wagon fast this book is excellent start. You will get introduction into Groovy and be able to use Groovy immediately as you finish with the book or related chapter of the book.

For those who have no knowledge about Java or Groovy I would not recommend this as a first book about Groovy. Even it is not stated that way, I believe that book expects at least some knowledge of Java.

The main minus for the book are poorly described closures. I believe that closures are really important part of the Groovy language and would expect better explanation. If you have no knowledge about Groovy closures, read some articles on the web to gain more knowledge about them.

Book is divided into 12 chapters.

Chapters 1 and 2 are introductory chapters describing in general what is Groovy, how to install it and how to integrated with the most popular IDEs.

Chapter 3 is dedicated to "special" (no Java like) constructs of language where you will learn about autoboxing, operator overloading...

Chapter 4 describes how to integrate Java and Groovy and vice versa. You will learn how to compile Groovy code to Java classes and how to solve some possible tricky dependencies issues.

In Chapter 5 you will see how you can use Groovy from the command line.

Chapter 6 is very interesting and you will see how easy it is to work with files within Groovy. This chapter is very useful for Java developers because they would ask themselves why Java file handling cannot be as easy. In Groovy you can read content of the file, you can list content of the file literally with the line of code.

Chapter 7 and 8 are even bigger "wows" for the Java developers. These chapters describe how Groovy handles XML. You will learn how to read XML file with XmlSlurper and XmlParser and how to create XML with MarkupBuilder and StreamingMarkupBuilder. For those that are used to to work with XML in Java this chapter will be proof that working with the XMLs need not to be painful.

Chapter 9 is devoted to web services and there is very nice introduction to different types of requests like: http get, post, SOAP request, XML-RPC request and others.

Chapter 10 is about metaprogramming. Metaprogramming is dynamic part of the Groovy language and the Groovy language option that make Grails so good web development framework. This is the chapter I liked the most.

Chapters 11 and 12 introduce Grails, web development framework based on Groovy.


Robert O'Connor said...

This book is one of my invaluable groovy resources! It's super useful in teaching you idiomatic groovy ways of solving problems :)

Jesus I sound like an ad.. But it's true :)

Roshan Shrestha said...

Unfortunately, the book doesn't cover regular expressions - one of the most difficult subject for Java/Groovy programmers. For a good introduction, look at Ted Naleid's article: Groovy: Don’t Fear the RegExp

John Flinchbaugh said...

I did notice the lacking of regex as well. I kept trying to look to this for some examples, and I kept coming up short. It was a great quick start into the language, though.