Tuesday, December 29, 2009

Getting Groovy

I bought a new book just before Christmas: "Grails. A quick-start guide" by Dave Klein. It's only a basic introduction to Grails development, but it covers enough material to give you a good idea of what Grails is all about.

I started with the book just in time for shiny new versions of Groovy and Grails to be released. It's always great to use the latest and greatest - unless your book is primed for the previous version :-) Fortunately, not too much has changed in the core of the tools, so following along with the book was still pretty straightforward.

The book is a great start if you've never used either Groovy or Grails. It assumes you have a basic understanding of web-app development and are comfortable in Java-land (though non-Java programmers wouldn't find it too difficult either).

The "plot" of the book is to develop a single, usable, web-application to handle the creation and management of community-based technical conferences. The book is broken down into iterations (chapters) where each iteration builds on the one before it. In true agile fashion, some iterations re-work material from the iterations before and each chapter leaves you with working code and a sense of accomplishment.

Following along with the book takes about one or two hours per chapter, so it's a pretty quick undertaking. There are a few bugs in the book's code (maybe "half implemented features" might be a better term). If you are like me, those things will drive you batty. For example, in chapter seven I spent nearly four hours tracking down a bug that caused a blank header to be displayed in one of the views. In the end the effort was worthwhile because it taught me a lot more about the life-cycle and relationship between Grails controllers, views and model objects than the book itself. But it was a bit frustrating to see loose ends in the code examples.

Overall I've really enjoyed the adventure so far. Groovy is a terrific language and Grails looks like an incredibly fast way to put real-world web apps into production. Having done my fair share of old-school Servlet/JSP development, Grails is an incredible leap forward in productivity.

If you're looking for a quick introduction to Grails, I can happily recommend the book. If the author is looking for ways to improve the next version, I'd recommend some tips on logging and debugging (had to find my own way around these issues). Also, a caution is in order about the example code: if you are using the latest versions of Groovy (1.7) and Grails (1.2) some of the example code doesn't seem to work. Perhaps there is an easy fix, but being a total Groovy/Grails noobie, I haven't taken the time to find the solution yet.

No comments: