Groovy is a Java-friendly kindof language. Java strengths: lots of reusable software, components and tools. VM and Binary compatibility, eases deployment. Allows for innovation at the source code level, as long as it produces JVM-compatible bytecodes. We reuse more than we write -- most code written is glue, bringing components together. Scripting is much better suited to this purpose. The reason for another Agile Language is that they want to be able to reuse all of the Java components and architecture that exist.
Groovy has been around since 2003, JSR-241. Has features of Ruby, Python, and Smalltalk. Uses ANTLR and ASM Java compilers (?). Features dynamic typing, with optional static typing. Native syntax for lists, maps, arrays, beans, etc. They also have closures -- chunk of code that can be passed around as first-class object. Regular expressions are built-in (w00t!). There is also native operator overloading, so if you add two arrays, the result is a concatenation. Basically, strings, lists, maps etc. work like you would expect -- Groovy takes care of a lot of the heavy lifting, and makes these things much easier to deal with. Groovy also adds some nice helper methods and such to the JDK.
They have a '?' operator, that will test an object for null, and cause the entire expression to return null, instead of returning an NPE. Expando (groovy.util.Expando) is a dynamic object. Create an Expando with some properties, and you can keep chucking stuff into it, in a free-form manner.
Groovy supports "currying" for closures, which is a little strange. It seems like it is the |var| thing in Ruby. Basically, you can define a block of code, which has some variables in it that you don't know what will be at the time of definition. Later, you can call the curry() method, and pass those data elements in. Groovy will fill in the variables in order - each time you call curry(), it will fill in the first, second, third, etc. variables.
Demos - XML-RPC is one of the cool features of Groovy. In the demo, there is a "groovysh" command, which is an interactive shell into the interpreter, much like Python or Ruby offers. There don't appear to be any semicolons at the end of line in Groovy. The demo shows Groovy interacting with Excel (using a wrapper around WSH), and then a Swing demo. Actions are properties of buttons, which is nice. Groovy looks like it could simplify cranking out quick Swing GUIs.
Some Groovy extras: process execution, threading, testing, SWT, Groovy Pages/Template Engine, Thicky (Groovy-based fat client deliver via GSP), UNIX scripting (Groovy API for pipe, cat, grep, etc.), Eclipse plugin (needs more work).
Perfomance isn't as good -- 20 - 90% of Java. Development time is much less than Java, but debugging kindof sucks. Ready for small non-mission critical stuff right now.
-Andy.
Posted by andyr at August 5, 2005 11:36 AM