Groovy is Coming…
Posted by jonchase
I’ve been trying to slowly integrate some Groovy into my normal Java coding. Here’s just one of the reasons why:
Java code:

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).
6 Responses to “Groovy is Coming…”
Leave a Reply
March 10th, 2008 at 11:24 am
Can you provide some Java vs Groovy benchmarks for your code?
March 10th, 2008 at 10:57 pm
I’m just about to post a follow up based on your question. Stay tuned.
March 10th, 2008 at 10:57 pm
[…] on from the previous post, here’s a very quick and dirty, completely unscientific, prone to error, your mileage may […]
March 12th, 2008 at 4:38 am
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)
}
March 12th, 2008 at 8:06 am
John -
Awesome - thx! I’ve still got lots to learn:).
March 12th, 2008 at 8:54 am
[…] 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 […]