Pages

Thursday, November 28, 2013

Making Java Groovy

Manning Publications recently published "Making Java Groovy" by Ken Kouson so I went and bought it. I often buy books about topics I'm interested in and read them on the train to work to find out if the described technologies can help me with my current or future projects. I really like Manning books because they are usually a good mixture between tutorial/reference and just good introduction into technologies.

Working in an almost Java-only environment have been interested in Groovy for quite some time. Most Java developers know the problem: You have all kinds of libraries or at least code snippets that already capture your business logic. But if you want to run a quick script to make use of it, you either have to create a full blown Java app with all it's draw-backs, or go for some other scripting language that can do the trick with as little code as possible; for my quick-and-dirty scripts I usually resorted to one of bash, PHP or Perl. For more complicated tasks I bit the bullet I wrote Java app, bundled into one big jar with a myriad of command line parameters to be able to switch environment, figure out best settings and what not.


Groovy seemed the solution for that mess but I hadn't gotten around to play with it. "Making Java Groovy" turned out to be a big hit. In fact it's probably my favorite Computer book of all times so far (and I have a lot...). The book is highly entertaining, Ken Kouson's writing style and quirky humor is just hilarious. The book is full of funny footnotes; while reading the book pretty much from the first page to the last I couldn't wait for the next footnote to come up.

Of course "Making Java Groovy" is also very educational. Within less than a week after starting to read it Groovy became my language of choice as a scripting language. If you already know Java and are looking for something to make your daily life easier you should definitely look at Groovy and Ken Kouson's book. What I like about it is that it doesn't follow the common pattern of creating one big application along the book but rather comes up with new ones to demonstrate the next feature in most cases; for a book describing a tool to make (smaller) daily task simpler a very appropriate concept. That makes it a lot easier to jump around in the book and read up on the features you're most interested in without the need to go back and read up on previous chapters just in order to understand the examples. But then - as I mentioned earlier - the book was so good I read it cover to cover anyways.

"Making Java Groovy" covers a lot of ground in just the right breadth for me. After only 3 train rides to work I could already solve one of my common use cases: I'm working a lot with AWS queues and DBs and frequently want to run a DB query in order to create test messages to put into an SQS queue. Since the book covers "Grabs" and "Grapes" as well as the simplified Groovy DB acces, solving this using the original Amazon SDK - which I already knew well - in a groovy script took only about 15 lines of code in a single script. And just yesterday I needed to compare 2 results from 2 Solr search queuries. Again, HTTP requests and JSON parsing were described in Kouson's book so I didn't even have to think about how to script that. All that about a week after my first real contact with Groovy.

When you're interested in finding out if Groovy is right for you, I highly recommend this book.

No comments:

Post a Comment