Summary
The Groovy project posted Release Candidate 1.0, with plans for a final release before the end of the month. RC 1.0 features a reworked Meta-Object Protocol, an improved and customizable type coercion mechanism, support for "in" as a boolean operator, move to a new syntax in closure notation, and over a hundred smaller improvements.
Advertisement
Groovy, the object-oriented scripting language for the JVM, was the first non-Java language to be officially supported in the Java Community Process, as JSR 241. Since it's inception, the language itself, as well as its implementation, has gone through significant revisions. This week, the Groovy project posted Release Candidate 1.0, with plans for a final 1.0 release before the end of the month.
One of the most significant changes in RC 1 is a new Meta-Object Protocol (MOP) that determines how methods are dispatched by the Groovy interpreter. Groovy's MOP, in effect, allows users to add and alter Groovy language constructs in order to customize the behavior of Groovy programs.
Groovy project lead Guillaume Laforge noted that,
This release contains a re-implemented and reworked Meta-Object Protocol, which is the core of Groovy's runtime system which decides how the dispatch of method calls, [and how] property and attribute access works. This new MOP brings more flexibility and a finer-grained control of those mechanisms.
Laforge also noted changes in Groovy's type coercion mechanism:
Among the interesting improvements, you'll note that coercion mechanisms are improved and now customizable for your own POGOs through the asType(Class) method. You can even coerce Maps to interfaces, as well as Closures to single-method interfaces.
Another new feature is full-fledged support for the in keyword as a boolean operator to support syntax such as:
if (5 in 0..10) { ... }
6 in 1..12 ? "yes" : "no"
Support for Groovy's old, pre-JSR closure syntax was discontinued in the 1.0 RC. Instead of specifying closures with syntax such as {|} and {||}, closures are now defined with code such as def cl = {a -> ...}.
In addition to those major changes, the 1.0 Release Candidate includes over a hundred minor enhancements and bug fixes, according to Laforge.
With a stable 1.0 release approaching, what role do you see Groovy play in your enterprise projects?
> >One of the most significant changes in RC 1 is a new > Meta-Object Protocol (MOP) that determines how methods are > dispatched by the Ruby interpreter. > > Please tell me that was a typo. You meant Groovy > interpreter right?
Indeed. Thanks for pointing it out. We corrected that now.
Its a shame much criticism has been heaped on Groovy(the project and the language) in the past.
It has a very nice syntax which makes excellent use of closures in the familiar brace enclosed syntax.
I wrote a web framework which used velocity for the view yet needed a scripting language for the controller and possible the data modeling.
I looked at several options and settled on Groovy(JSR-02 release at the time). Its access to Java libraries, clean API, straightforward JDBC, and very nice expandability made it a great choice I haven't regretted.
Making a new command like:
foo(bar,100) { baz(); }
is childs play. You simply cannot downplay this kind of flexibility.
We certainly have room for more than one scripting language. Here is hoping the community wholeheartedly accepts Groovy.