When discovering that I’m a keen advocate of Groovy, people sometimes ask … “but why Groovy?”
To me, if there’s a job to be done, it shouldn’t always have to be done the same way you would’ve always typically done it, particularly if there is a more interesting and efficient way.
The Groovy language is uber-Java, without much of the ugly. It let’s you get straight to your issue of solving a problem, without having to boiler plate up some classes to compile.
With Groovy, you can just run the script.
Groovy is commonly referred to as a scripting language and is particularly attractive as glue-code scripting to fit those little tasks that you’ve probably repeatedly been doing manually. Some examples:
- updating some configuration in a database
- building a package of files
- extracting a value from a database
Getting started can be as simple as writing Java-like code in a file (typically with a .groovy extension):
//saved as MyGroovyFile.groovy System.out.println("Hello, World!");
To make it more groovy than java-groovy, it is even simpler:
//saved as MyGroovyFile.groovy println 'Hello, World!'
This is made simpler because Groovy imports Java’s System.out library (and many others) by default and one extra bonus: Groovy doesn’t need semi-colons!
Let me know how you get on.