Groovy is Coming…

Posted by jonchase

Here comes GroovyI’ve been trying to slowly integrate some Groovy into my normal Java coding. Here’s just one of the reasons why:


Java code:
The Java code

Groovy code:
The Groovy code

Note that this reduction in complexity happens almost everywhere I choose to use Groovy over Java. Of course there are myriad other ways I could have done this in Java (I even tried Xstream but I couldn’t figure part out so I gave up). The point is that the first way I chose to do it in Groovy was natural, expressive, and easy.

Groovy is not going away any time soon. If you’re a Java developer and wish you could move faster, buy the book, read it, and then start integrating Groovy into your daily programming a little at a time. You’ll be happy you did.

And don’t even get me started on Grails

Update: here are the second and third posts in this series (benchmarks included).

Subscribe to Jon's Blog Subscribe


6 Responses to “Groovy is Coming…”

  1. Alexey Says:

    Can you provide some Java vs Groovy benchmarks for your code?

  2. jonchase Says:

    I’m just about to post a follow up based on your question. Stay tuned.

  3. Groovy Micro Benchmark | Jon Chase's Blog Says:

    […] on from the previous post, here’s a very quick and dirty, completely unscientific, prone to error, your mileage may […]

  4. John Wilson Says:

    It can be written a little more concisely in Groovy

    def contacts = new XmpSlurper().parseText(contactsXml).contacts.collect{ contact->
    new Contacts(name: contact.@name, email: contact.@email)
    }

  5. jonchase Says:

    John -

    Awesome - thx! I’ve still got lots to learn:).

  6. Groovy Micro Benchmark Revisited (Groovy is fast…) | Jon Chase's Blog Says:

    […] decided to rerun the test for Groovy because of a comment John Wilson left on the first post. He suggested this more concise syntax for the Groovy […]

Leave a Reply