Groovy

Groovy

Dynamic language for the JVM

Description

Writing a thirty-line script on the JVM in plain Java means a project, a class, a public static void main, and a try-with-resources block just to read a file. Groovy drops the ceremony — a .groovy file runs straight from the command line, while still calling every Java class and jar you already have, so nothing has to migrate between ecosystems.

The syntax is Java's close relative: paste Java in and it is usually valid Groovy already, then shorten it with closures, collection methods and string interpolation as you go. Types are optional, and adding @CompileStatic brings compile-time checking and Java-grade bytecode back. Gradle build scripts and Jenkins pipelines are written in it, so anyone who has touched either has been writing Groovy all along.

Features



Java interoperability: import existing Java classes and third-party jars directly, and call compiled Groovy classes from Java, with no glue layer in between.

Closures and collections: each, collect, findAll and groupBy work straight on List and Map, collapsing a screenful of Java looping into a couple of lines.

Interactive shells: groovysh tries statements in a terminal, and groovyConsole is a small window with an editor above and output below for edit-and-run cycles.

DSL support: optional parentheses, command chains and operator overloading make it a natural host for domain languages — build.gradle is exactly that.

Static compilation: annotate a class or method with @CompileStatic or @TypeChecked to get type checking at compile time and bytecode on par with Java.