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 newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags javasoftware developmentSQLprogrammingprogramming languageSpringSourcegroovy

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

Cool Tech

Toys for Boys

Family Friendly

Stocking Stuffer

SmartLens - Clip on Phone Camera Lens Set of 3

Learn more >

Christmas Gift Guide

Click for more ›

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Aysha Strobbe

Microsoft Office 365/HP Spectre x360

Microsoft Office continues to make a student’s life that little bit easier by offering reliable, easy to use, time-saving functionality, while continuing to develop new features that further enhance what is already a formidable collection of applications

Michael Hargreaves

Microsoft Office 365/Dell XPS 15 2-in-1

I’d recommend a Dell XPS 15 2-in-1 and the new Windows 10 to anyone who needs to get serious work done (before you kick back on your couch with your favourite Netflix show.)

Maryellen Rose George

Brother PT-P750W

It’s useful for office tasks as well as pragmatic labelling of equipment and storage – just don’t get too excited and label everything in sight!

Cathy Giles

Brother MFC-L8900CDW

The Brother MFC-L8900CDW is an absolute stand out. I struggle to fault it.

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?