Groovy is a popular, open source, dynamic language residing on the Java Virtual Machine. Born in 2003, Groovy offers Java developers an almost-zero learning curve while gaining inspiration from Python, Ruby, and Smalltalk, according to its developers. Complementing it is the Grails open source Web application framework, which leverages Groovy.
InfoWorld Editor at Large Paul Krill recently spoke with Groovy project lead Guillaume Laforge and Grails project lead Graeme Rocher about what to expect in future versions.
InfoWorld: Why does Groovy exist?
Laforge: Initially, Groovy was created as a companion to Java, rather than as a replacement. The idea was to be able to simplify certain aspects of the Java language to make Java developers more productive.
InfoWorld: What are the main benefits of Groovy, and what differentiates Groovy from other languages, such as Ruby, Scala, Python, or Java itself?
Laforge: We wanted to complement Java by offering new features that were available from other languages, such as Ruby, Smalltalk, and Python. In terms of syntax and look and feel, it looks very much like Java. So it's very easy for Java developers to learn Groovy.
InfoWorld: What's the advantage of using Groovy instead of just using Java?
Laforge: You can make the code more expressive, for example, for defining your algorithms, whereas a language like Java is usually more verbal. So in terms of maintenance, because you spend more time reading your programs more than you spend writing them, it's even easier to read and maintain the code. And we bend the Java syntax to allow the creation of domain-specific languages. Because the syntax of Groovy is very flexible and you can write almost-plain-English sentences, business people are easily able to write business rules and domain concepts in a concise and very readable way.
InfoWorld: The latest version of Groovy was version 2.0, released in June. What are the principal improvements in it, and what improvements are planned for future versions and when might those arrive?
Laforge: There are essentially three big things in Groovy 2.0. Let's start with what I call the static theme. Groovy's nature is to be a dynamic language, but we also added new features, such as static type checking. We also built on that feature to do static compilation, which is about generating the same kind of bytecode as the Java C compiler. The net result is that you've got the same kind of type safety as you have with a language like Java, as well as the same speed as Java.
Typically, dynamic languages are slower than Java. But Groovy is very, very fast, thanks to those features, and they are safe to use for Java developers.