In association with heise online

28 June 2012, 15:51

Groovy 2.0 introduces static type checking and compiling

  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

Groovy logo

The Groovy developers have released version 2.0 of the dynamic, object-oriented programming language for the Java Virtual Machine (JVM). Despite being a dynamic language, the new version includes a static type checker and the option to statically compile parts of applications. Groovy 2.0 also includes syntax enhancements, improved modularity, and makes use of the invoke dynamic feature in JDK 7.

Since many Java developers use Groovy in embedded situations as an extension language, the latest version introduces static type checking. In these use cases, developers were expecting the same kind of error messages from the Groovy compiler that they are used to from Java. If developers use the @TypeChecked annotation in their code, the Groovy compiler will perform static type checking at compilation time and report the most obvious errors like typos in variable names. The static type checker also verifies return values of assignments. Developers can mix statically typed methods with the dynamic features of the language and opt out of type checking for code that benefits from Groovy's dynamic features.

Groovy 2.0 supports the new invoke dynamic instruction of version 7 of the JDK. This enhances the performance of Groovy's dynamic calls when using this version of the JDK. Since JDK 7 is not widely deployed yet, the developers have also included the ability to statically compile type-checked code with the new @CompileStatic transform. This release also includes several syntax enhancements from the Project Coin improvements to Java.

To make the project more modular, Groovy 2.0 splits the original Groovy JAR file into several small modules organised by features. This made the core Groovy JAR half the size and therefore more portable. Users of the language can now pick and choose and only use the modules they actually need in their programs. One upshot of this development is newly added support for extension modules. Groovy's modules can now provide methods to other classes, including to those from the JDK or other libraries. Those extension methods are fully supported and understood by the static type checker and compiler.

The developers had initially planned to release this version of Groovy as version 1.9 but the large number of new features have prompted the developers to name it Groovy 2.0 instead. From now on, the developers are planning to release a major version every year, with Groovy 3.0 being released next year.

Detailed information about this release can be found in an article by Groovy project manager Guillaume Laforge on InfoQ. Groovy 2.0 is available for download from Codehaus.org and is licensed under version 2.0 of the Apache licence.

(fab)

Print Version | Send by email | Permalink: http://h-online.com/-1628119
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit