tags:

views:

58

answers:

1

I'm versed in Java, and starting to experiment with Groovy. Because the two are integrated so well, I find myself writing in Java whatever I can because it's so easy. What specific tips can you offer that would speedup my work with Groovy?

Meaning - in what areas do groovy excel over java, and where should I stick to Java?

+1  A: 

Some of the main things I like groovy for:

  • testing is probably the biggest win. The ability to change behavior at runtime and mock out methods is one of the greatest things about groovy. Convert your test suites to groovy now!
  • use the builders. Groovy builders have so much more expressiveness than traditional java. In particular, the MarkupBuilder for embedded snippets of XML or HTML is 1000s of times nicer to use than vanilla java
  • GPars if you're doing any sort of concurrent programming or threading

Also see Hidden features of Groovy and Why would one use Groovy over Java.

Where I'd stick with java:

  • any place where speed really matters, stick with java. You still pay a high cost in performance for groovy's dynamic nature.
ataylor