Skip to main content

Getting started with Groovy

Posted by simongbrown on August 24, 2004 at 2:34 PM PDT

Having briefly looked at Groovy in the past, I don't think I've ever really "got it". Even when I saw the Groovy presentation at JavaOne a couple of months ago I was still undecided. I've never been a big fan of scripting languages because I like what Java gives me as a developer - structure and flexibility while also being easy to write. Throw in a whole bunch of third party APIs and you can put together even fairly complex programs in a short amount of time. So why should I pick up something like Groovy?

While I still can't see myself writing Groovy applications for clients just quite yet, even on my current project there are many opportunities. For example, I've written several small Java applications that clear down JMS queues by consuming any messages that are left sitting around. We also have a massive Perl script that takes some timing information from performance tests and analyses it. I also have a library of SQL scripts that I run through TOAD when I need to clear down the database or do a quick SQL query. All of these tools are very different yet they all have one thing in common - we've had to put work into getting them to work and they can all be written with a Groovy script. This means no more public static void main() and a single language/environment that we can build all these tools in.

Although there's a learning curve associated with the language, getting started with Groovy is easy. Download it, set some environment variables and you're off. For my experimenting I've been using the Groovy Console - a Swing application that you can type a Groovy script into and click Run when you've finished writing it. I can see myself using this more and more as the weeks go by and hopefully I'll be able to build up a useful collection of Groovy scripts as I do. If you've not tried Groovy yet, download it and have a play because you might be pleasantly surprised.