The new version of the Groovy programming language aims to make life easier for programmers who work with Java and SQL, the language's developers note.
The new features include some old Java functionality that may help Java programmers work more easily with Groovy. It also includes some additions that ease the burden of working with SQL-based databases.
Groovy is one of a a growing number of languages that run on Sun Microsystems' JVM (Java Virtual Machine).
Conceived in 2003, Groovy was developed as a Java-like language customized for tasks that Java itself fumbled at, such as XML parsing. Using Groovy, Java developers can work up scripts and codes without worrying about the sometimes considerable amount of boilerplate code that accompanies full-scale Java programs, said Guillaume Laforge, the head of Groovy development for SpringSource, a Java application infrastructure management software provider.
By running on the JVM, Groovy can also use the myriad Java libraries that are available.
Laforge noted that since its formal introduction (version 1 wasn't released until 2007), Groovy has a found a niche in several different tasks, such as developing prototypes of Java programs. In conjunction with the Grails rapid development framework, it has also been used to quickly stand up and run database-driven Web applications.
Version 1.7 of the language includes a number of different features to help aid in these jobs, Laforge described.
One feature is support for anonymous inner classes and nested classes. Such support has long been available in Java, but earlier versions of Groovy eschewed them in favor of supporting a similar technique known as closures. Both approaches allow developers to code in such a way that it isn't necessary to write a new class for every possible business rule that the program may encounter.
While the maintainers of Java are now considering the use of closures, Groovy will support the anonymous inner classes and nested classes so that Java programmers may more easily work with Groovy, Laforge said. This inclusion will also allow Java frameworks that rely heavily on anonymous inner classes to work more seamlessly with Groovy as well, he added.
Greater compatibility with SQL has been attempted with the new version of Groovy as well. Laforge noted that administrators have written Groovy scripts to migrate "big batches of data from one system to another," he said. A lot of traditional scripting languages don't work very well with SQL and writing a Java program for the task may be overkill. Groovy 1.7 features a new method that allows data to be moved by batches, which should simplify the writing of the migration scripts. It also features a similar method for transaction processing.
Other new features to Groovy 1.7 include improved support for annotations and assertions. The GroovyConsole and the Abstract Syntax Tree interfaces have been improved and the GroovyScriptEngine has been rewritten. The developers have also released a Microsoft Windows installer for Groovy. Grails has recently been updated as well.
Groovy, which is open source under the Apache license, is updated once a year, Laforge said. Plans for version 1.8 include performance improvements. Programs written in dynamically compiled languages, such as Groovy or Ruby, typically run (PDF) more slowly than those compiled ahead of time, in statically compiled languages such as Java.
Groovy, in particular, has been criticized for slow performance. The developers did not do much work on 1.7 on improving performance, Laforge said, though that will be more of a priority for version 1.8.
Another priority for Groovy 1.8 will be additional enhancements to aid in the developing of domain specific languages, or DSLs. DSLs are languages with keywords customized for some specific task. DSLs can be used to write business logic in such a way that it can be understood by non-programmers.
Given its comparatively simple syntax and extensibility, Groovy could serve as a base for building out DSLs, though Laforge said he would like to see more work done at cleaning up some of the "syntactical noise" of the language, such as commas and semicolons.
"We got some ideas on how to further streamline the syntax to allow nicer-looking DSLs, which will look more like normal English," he said.