February 27th, 2008


Anyone experienced with Groovy?

Okay, yes -- I'm always a little attracted to the latest bright and shiny language to come down the pike. But having gotten genuinely irritated at Java's shortcomings compared to C#, I've started looking into alternatives. One of the reasons I chose Java in the first place is the fact that there are about a million languages that run on the JVM, so I knew that I would have some options.

(And an aside: I'm very amused to see on that list that AdaMagic is still being sold, as is AppletMagic, the Ada->JVM port. I was part of the original development team for that, way back in something like '93. I was, as usual, the guy doing the weird stuff -- on a team otherwise made up entirely of compiler folks, I was the one writing the initial IDE, to show that it could be done. One of the most fun projects I've ever done, pulling together a full IDE in a few months, out of a mix of Common Lisp, Emacs and assorted packages for them. Anyway...)

When I first glanced at Groovy, many months ago, I wasn't so impressed: they make it *sound* like it's just a scripting language that runs on the JVM. But now I'm looking at it more seriously, and my opinion is rapidly shifting. It looks to be almost a strict superset of Java -- syntactically *very* close, but adding on all the stuff that I've been missing. Indeed, it appears to add exactly the bits that I most like from Ruby (good closures), Perl (good regular expressions), Lisp (easy meta-language definition), ActionScript (flexible mixing of typed and untyped programming), [ETA:C# (good property and event support)] and assorted other enhancements.

I wouldn't exactly call the language *elegant* -- it suffers a bit from Perl's "throw in every possible language feature" disease -- but it looks like I could write very elegant programs in it, and that's what I mainly care about. In particular, it might suit my API layer extremely well: that's mostly a bunch of straightforward data-manipulation code, and I desperately want good closures for it. (I'm currently working with anonymous inner classes, but they are an irritatingly bad substitute for problems that are essentially functional in nature.) I suspect that it would be horribly slow, but I don't know that I care much -- realistically, this mid-tier code is probably a tiny fraction of the actual execution time. (The app is mostly DB-bound.)

So: anybody have any insights on using Groovy in practice? The site makes it sounds great, but I'd be especially interested to hear if folks have heard about negative experiences with the language...