Section 2. About Groovy
In this section you'll learn the basics of Groovy: what it is, how it relates to the Javalanguage and the JVM, and some of the highlights of writing Groovy code.
What is Groovy?
Groovy is an alternate language for the JVM —
meaning that you can useGroovy for Java programming on the Java platform in much the same way youwould use Java code. Groovy code combines well with Java code when writing newapplications, and can also be used to extend existing ones. Groovy currently is inversion 1.5.4 and works on the Java 1.4 and Java 5 platforms, as well as Java 6.One nice thing about Groovy is that its syntax is very similar to the syntax in theJava language. While Groovy's syntax was inspired by languages like Smalltalk andRuby, you can think of it as a simpler, more expressive variation on the Javalanguage. (Ruby is different from Groovy in this regard, because its syntax is quiteunlike Java syntax.)Many Java developers take comfort in the similarity between Groovy code and Javacode. From a learning standpoint, if you know how to write Java code, you alreadykind of know Groovy. The main difference between Groovy and the Java language isthat Groovy lets you write less code (sometimes far less!) to accomplish the sametasks you might labor over in your Java code.
As you begin playing with Groovy, you'll find that it makes everyday programmingactivities much quicker. You'll know a lot about Groovy's syntactic shortcuts by thetime you're done with this tutorial. For now, just consider these highlights:• Groovy's relaxed Java syntax allows you to drop semi-colons andmodifiers.• Everything in Groovy is
unless you state otherwise.• Groovy permits you to define simple scripts without having to define aformal
object.• Groovy adds some magical methods and shortcuts on normal everydayJava objects to make them easier to work with.