Groovy is a dynamic language that integrates seamlessly with the Java platform. It offers a syntax that mixes ideas from Java, Smalltalk, Python and Ruby, and lets your reuse all your Java libraries and protect the investment you made in Java skills, tools or application servers. Version 1.0 was released this week.
Groovy is a dynamic language for the JVM that integrates seamlessly with the Java platform. It offers a Java-like syntax, with language features inspired by Smalltalk, Python or Ruby, and lets your reuse all your Java libraries and protect the investment you made in Java skills, tools or application servers.
Groovy has been under development in fits and starts for several years, causing many people (such as myself) who were excited at first about Groovy to be put off by the whole exercise. But with 1.0 finally out, this would be a good time to forget everything you know about Groovy and take a second look.
Groovy can be used for various purposes, from adhoc shell scripting leveraging Java APIs, to full-blown web applications built on Spring and Hibernate through the Grails web framework. It can also be integrated very easily in your applications to externalize business logic, create domain-specific languages, or to provide templating capabilities, and much more.
Groovy compiles straight to Java bytecode in either application development or scripting mode. Here's an example of a simple Groovy script that prints Hello, World:
def name='World'; println "Hello, $name!"
Semicolons are sometimes required, and sometimes optional. The same goes for parentheses. Usually type names can be omitted but in many cases you'll need to use the 'def' keyword to define a variable. See the resources for more information.