New Groovy cozies up to Java, SQL

New version of the language features a few old Java class tricks

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.

Last month, SpringSource, a division of VMware, and the community of volunteer developers behind Groovy released a new version of the dynamically compiled language.

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.

Developers can use most major IDEs, such as Eclipse, IntelliJ Idea and Netbeans, to write Groovy programs.

Join the Good Gear Guide newsletter!

Error: Please check your email address.

Tags software developmentSpringSourceprogramming languageprogrammingjavaSQLgroovy

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Joab Jackson

IDG News Service
Show Comments

Most Popular Reviews

Latest News Articles

Resources

PCW Evaluation Team

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?