Monday, February 12, 2018

Groovy: Language Evolution and Usage

After the initial release, the Groovy language continued to evolve and progress. Below are key features with each major release, not including pending releases.

Groovy 1.5

  • Added support for key conventions added in Java 1.5, including
    • Annotations - syntactic metadata added to classes and methods for use by the compiler and at runtime.
    • Enumerations (enum) - named lists of pre-defined constants
    • Static Imports - importing static methods from other classes into a class o Generics
    • Classical for loop
  • Domain Specific Language - the ability to extend the language with domain specific naming, allowing programmers to work with language and structures that are specific to their domain and have them mapped to the appropriate Groovy code
  • Elvis Operator - a simple conditional of <test> ? <ifTrue> : <ifFalse>

Groovy 2.0

  • Static type checking - while Groovy is an optionally typed language, version 2.0 added the ability to indicate that static type checking is required for a class
  • Static compilation - added the ability to compile objects as native Java classes rather than using the meta object protocol
  • Implemented additional Java 1.7 features
    • Binary literals
    • Underscore literals
    • Multi-catch blocks
  • Extension Modules
  • Contributing instance and static methods (similar to adding to a JS prototype) 

Groovy 2.1

  • Compile time meta-annotations
  • The GPars 1.0 concurrency and threading library was included
  • Definable custom base classes, allowing a programmer to select which base class to extend for a Groovy object rather than the language defined one

Groovy 2.2

  • Better interaction with Java 8 lambdas

Groovy 2.3

  • Official JDK 8 support
  • Traits
  • Template markup engine - a mechanism for formatting text output

Groovy 2.4 (current)

  • Support for writing Android apps in Groovy
  • Other enhancements

Usage

While the Groovy language was not targeted at a specific industry or vertical sector of the programming language market, like ADA for example, it has been embraced in web development circles, including the Grails web application development framework.  It also provides the core language for Samsung’s SmartThings home automation platform.

No comments: