Waiting for Groovy 1.8

Groovy 1.8 is going to be released in December 2010. First beta release is already open to download and second beta release will be ready in September.

Groovy developers team preparing for us a few important surprises.

They added more AST transformations, for different cases like @Canonical, @EqualAndHashCash, @ToString and many others. You may use such annotations to generate toString(), equals(), hashCode() methods on compilation. @InheritConstructors helps to generate inherit all parent constructors, and here is link to task.

Another interesting feature is Closure composition, so now it's possible to use special syntax to compose multiple closures, like:

def log = { a -> println(a); a }
def save = { a -> dao.save(a); a}
def notify = { a -> notificationService.notify(a); a }

// so now instead of calling notify(save(log(user)))
// you may call it like
def action = log >> save >> notify
action(user)

// or even like
notify << save << log << user // is that awesome or awful?!

Also they prepared few performance improvements: avoiding calling methods when it's not necessary and processing operations on integers as primary type values but not objects (like, incrementing or adding). As result Groovy can be used for mathematical calculations without performance issues. In this presentation you can read much more about this. And here are related jira tasks so anyone can watch the progress.

This issue is fixed so they can't say that "Ruby is right, Groovy is wrong" anymore :)

Annotations now can accept closure as argument:

@Validator { password.size() > 6 }
String password

This task contains more information and links.

Closure currying is a powerful thing. And now it's possible to curry right and 2nd (of three) parameter. Moreover no need to wait Groovy 1.8 to try this, because it's available right now and right here, starting from version 1.7.2 of course ;)

Well, that's all about this for now. Waiting for Groovy 1.8 and for more interesting things to be released this December.

6 comments:

MyOpenDraft said...

Nice post, thanks for sharing, additionally there is new proposal for GEP 3 - Command Expression which help us to build nicer DSL in Groovy.

Check this:
http://docs.codehaus.org/display/GroovyJSR/GEP+3+-+Command+Expression+based+DSL

Ruslan Khmelyuk said...

Hi Alireza,

Really useful stuff. Thanks for posting this link.

Looks like they're going to release it in next Groovy 1.8 beta version.

Task status can be tracking here http://jira.codehaus.org/browse/GROOVY-4384

Hamlet D'Arcy said...

Don't forget the @Log annotation. This will be a big hit.

Hamlet D'Arcy said...

@MyOpenDraft The GEP Command expression stuff seems to have stalled out. The proposed solution is complicated (IMO) and the discussions have stopped on the mailing list. It would be great to get more readers of the GEP and more comments on the mailing list. That would help push it back to the limelight.

Ruslan Khmelyuk said...

Thanks Hamlet for your notices and for @Log patch too! I hope Groovy team will integrate it into Groovy 1.8 till next beta release ready.
Want to play with it more.

Peter Niederwieser said...

@Hamlet Stalled out? It's already in trunk. Or did you expect more than that? http://groovyconsole.appspot.com/script/226001