Jython vs. Groovy smackdown
May 5, 2004 19:52 · 310 words · 2 minute read
OK, sorry for the headline. Tim Bray recently wrote a bit about Jython. I agree wholeheartedly about the use of dynamic scripting languages with Java. I also agree that Jython is a very fine product and love the Python language.
But, when looking to do scripting on top of Java, I think Groovy is going to be a great choice. The big trouble with scripting your Java apps in Jython is that you need to make the mental shift over to Python syntax. With Groovy, most legal Java syntax works just fine. So, if the Java-ism for doing something is what comes to mind quickly, you can write it that way. The times when you’re trying to really save on some work, you do things in a more Groovy way.
Jython does have the maturity advantage, as Tim points out. The ability to use premade libraries written in Python or Java is a bonus… just remember, though, that Python libraries tend to be rather, well, Pythonic. This is a good thing, if you’re a python geek like me, but might make things a little less intuitive for people who are used to doing things the Java way.
I’ve been following the discussions on the groovy-user mailing list (and will probably join the JCP list), and I think there’s a good direction there. People are conscious of the tradeoffs between being Java-like, and building conveniences into the language.
Groovy works quite well already. If you haven’t tried it, give it a whirl. Once the Eclipse plugin works in new Eclipse builds and has the spiffy testrunner that I’m used to, I plan to start using Groovy for unit tests. I’ve already found a good minor role for it in the app we’re building as well. So, though I’m a Python fan, I think Groovy is the finer scripting choice for Java.