The Source for Java Technology Collaboration
User: Password:



Simon Brown

Simon Brown's Blog

Getting started with Groovy

Posted by simongbrown on August 24, 2004 at 02:34 PM | Comments (4)

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.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Runtime customizations -- JMS Message Selectors
    Simon,

    I'm planning on using a scripting language (maybe Groovy) in SomnifugiJMS for message selectors. It seems like a nice fit, and keeps me out of the byte code manipulation business.

    I think scripting languages are a good fit for focused customization. Macro writing in UIs, math interpretters, and generally leaving the door open for someone downstream from the compiler to glue two things together.

    Dave

    Posted by: dwalend on August 25, 2004 at 07:54 AM

  • Runtime customizations -- JMS Message Selectors
    The thing with Groovy I find is that it gives you the opportunity to choose whether you're going to write highly structured code, or not!

    Even in Enterprise software development it's often nice to have the choice (like unit tests, prototypes etc.). Of course if Groovy manages to support both models then you can make the decision without switching languages - but that feels far away at the moment :-)

    Btw. I like the idea of of non-SQL-92 selectors! I was just thinking that the other day, funnily enough, that it would be great to have a more flexible syntax. Isn't there going to be quite a cost though in executing arbitrary code on each message?

    If anyone is interested in learning more, I'm going to be posting a regular series of code snippets from next week on http://www.justgroovy.org

    Kind regards
    Neil Ellis

    Posted by: neilellis on August 26, 2004 at 04:05 AM

  • Tools Integration/plugins
    I've recently started playing with Groovy to create plugins for MagicDraw. I do have some classloader issues (that I hope to resolve sometime).

    I think that scripting language for tools integration or to create plugin is really nice. If I need a quick fix for something that's missing from a product, bulding it with script will allow me to get going faster. Because pluging coding is not something that I do frequently, being able to modify scripts without having to restart the tool let me play and discover stuff, about the tool API, more easily.

    Posted by: epirsch on August 26, 2004 at 04:30 AM

  • Judoscript
    Groovy is fine, but of course, it requres YAS (yet another syntax). I like judoscript (www.judoscript.com) mostly because it gives similar syntactic sugar as groovy, but uses the more familiar syntax of Javascript. Beanshell can also meet this need...

    Just some thoughts,
    Michael
    http://www.nettakeaway.com/tp/

    Posted by: mwexler on August 28, 2004 at 09:51 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds