Groovy: New Scriptings

Just in time for the new fall school year, Groovy appears as an extension to Java. I identify Groovy as new scriptings; but that is really not true. Groovy, which can be best thought of as an extension to Java syntax has a compiler that produces JVM bytecode. More importantly Groovy and Java classes are interchangeable. There is already an Eclipse plugin for Groovy and you can download a developer kit from the same website.

In fact, Groovy has a superior website with excellent sources of information about the product, its documentation, how to get started and where it all fits in the Java scheme of things. And Groovy fits in as an extension of Java that Sun has already said will influence its Java 5 through 7 versions due probably up to and including Longhorn time. And Sun would do well to pay attention to what Groovy is doing – and follow with sincerest form of flattery in the IT business – copy some of the very groovy ideas .

The Groovy Ideas

The Groovy people descibe their language as follows: “Groovy is a new agile dynamic language for the JVM combining lots of great features from languages like Python, Ruby and Smalltalk and making them available to the Java developers using a Java-like syntax.” Indeed Groovy syntax is a close clone of Java with almost all of the same keywords but with a few well chosen extensions. First, Lists ([1,2,3,999]) and Maps ([12: “Finish”, 6 : “midpoint”, 1″Start”]) like PHPs arrays become first class citizens in groovy. “for” clauses, “switch/case” statements and the new closures – (think of closures as code objects or as dynamic macros or the opposite of structs – classes with code but no variables except as passed parameters. Finally, like preliminary views of Borlands as yet stillborn scripting language Lovelace, Groovy has its own substitute XML/DOM/Ant markup language. In the case of XML it takes this:

  The End of the XML Brackets

and in Groovy markup becomes:

  book(author: "James Jacques"){
      title = "The End of the XML Brackets"

Groovy as well has such ideas as Groovlets being a smoother way of creating Java Servlets; GSQL for making smoother database connections; operator overloading and regular expression direct support long overdue in Java. But one of the most intriguing possibilities is the combination of the Groovy templates and direct support of Ant Scripting in Groovy – this combination is perfect for the wild and wooly field of dynamic code generation -dBase and Clipper freaks rejoice; security administrators cringe!

So Groovy is crammed with refreshing ideas on how Java might evolve – its reasonably stable, easy to install and definitely worth the look/see/test.


Pin It on Pinterest