When I get the paperback copy of the "Programming Groovy 2" book back in the June 2017, I was wondering if I can find something new or exciting in the book that was written in July 2013. It took me almost 1,5 year before I have finally put the book on my desk and started reading and playing around with the examples. As a veteran Groovy developer, I have to say - it was worth it!

If I have to describe the book in only one sentence, I would say that "Programming Groovy 2" is the most pragmatic and gentle introduction to the Groovy programming language. Instead of explaining all possible features and use cases it focuses on the following major areas:

  • a practical introduction to the language,

  • using Groovy to solve day-to-day tasks,

  • experimenting with metaprogramming to get even more from the language.

What’s inside?

In the first part of the book, you will learn the differences between Groovy and Java. Reading this part of the book was more exciting back in the days before Java 8 because the concepts like closures or collections bulk operations had no equivalents in the raw Java language. However, it still contains a lot of important and interesting information, like dynamic typing or working with Groovy strings to name a few - something that any newcomer will appreciate and learn a lot from.

Part 2 focuses on the 3 practical use cases: working with XML files, connecting and querying the database, and using Groovy as a scripting language. It also covers one funny, at least for me use case - using Groovy SQL to query Excel document through JDBC interface. I was completely unaware that you can do something like that, I just never worked with Excel documents that way. It would save me much time if I knew that a few years earlier.

Part 3 introduces metaprogramming capabilities and shows various ways you can apply it for your own needs. Starting from simple method injection at the runtime, up to AST transformations applied during the code compilation phase. It explains in details Groovy’s MOP (meta-object protocol) layer, and if you ever wonder how does Groovy handle dynamic method invocation, the answer is here.

Part 4 closes the book with a few extensive examples of Groovy metaprogramming in action - builders, mocking and building DSLs. The previous part gives a solid foundation to understand the language’s dynamic nature and capabilities of MOP (and its limitations). The last part of the book puts everything into action making the story complete.

Who is this book for?

Venkat Subramanian has his unique and effective style of teaching. I’ve read "Programming Groovy 2" after spending 7 years with Groovy, and I still found it interesting and worth reading. The book aged gracefully and even though it covers Groovy version 2.1.1, it is still the right choice to start a journey with Groovy with it. It covers fundamental language concepts that didn’t change much since 2013. So if you want to give Groovy a chance and you are looking for a practical guide - this book is definitely for you. Also, if you are already in the ecosystem and you want to improve your understanding of the language and its powerful features, you will also find "Programming Groovy 2" an exciting lecture. Tons of practical examples, very natural and smooth writing style, and a great learning experience - and all of it in a book with 300 pages. You can work it out in one weekend with the fast pace, or you can relax and split the experience into a several 1-hour long learning sessions. Whatever works for you best.

Programming Groovy 2: Dynamic Productivity for the Java Developer

The strength of Java is no longer in the language itself; it's in the Java Platform (the JVM, JDK, and rich frameworks and libraries). But recently, the industry has turned to dynamic languages for increased productivity and speed to market. Groovy is one of a new breed of dynamic languages that run on the Java platform. You can use these new languages on the JVM and intermix them with your existing Java code. You can leverage your Java investments while benefiting from advanced features including true Closures, Meta Programming, the ability to create internal DSLs, and a higher level of abstraction. (source: goodreads.com)

The above links are affiliate links. If you decide to buy a book using my affiliate link, I will get a small percentage from your purchase. The affiliate link does not affect the final price of the product. Using it costs you nothing.

Bonus: how did I get my copy of the book?

I got my paperback copy in June 2017. I was lucky enough to draw a book prize during Toruń JUG Day event with Venkat Subramanian. It was the second time I had a pleasure to meet Venkat in person and spent time on talking not only programming related topics. It was such an excellent experience! Venkat is not only a great teacher but also one of the kindest person I have ever met in the tech industry.

Thank you!

Thank you so much for reading up to this point! I hope this article met your expectations, and you have learned something valuable from it. If you have one more minute, leave me a comment below, please. This way, I can thank you for your time more in person.

And last but not least. If you find this blog post valuable, help me spread the word, please. You can share it on Twitter, LinkedIn, or anywhere else you can think of. This single tweet or post on social media helps a lot. One more time - thank you so much! You’re awesome!

(PS: Check "Related posts" below for more content like this one.)