A Groovy Alternative


Jython is a mature Java implementation of the well-established scripting language Python. Groovy is a relative newcomer to the scripting scene, but it is gaining such interest that it threatens to eclipse Jython as the Java developer's preferred scripting language.

Like Jython, Groovy is 100% Java and offers the same seamless integration with the Java platform. Unlike Jython, Groovy is not a Java implementation of an existing scripting language but is designed from the ground up for use by Java developers, although it does borrow some of the best features from languages such as Python, Ruby, and Smalltalk.

Groovy's creators, Bob McWhirter and James Strachan, intended the language to feel immediately familiar to Java developers and stayed with the curly braces. You can even use semicolons, but they are optional, presumably for those of us who can't get out of the habit.

Functionality wise, there is little difference between Jython and Groovy, although Groovy may look a little slicker in the tools it provides. Groovy even has the equivalent of Jython's servlet, known as a Groovlet.

What makes Groovy so interesting is its acceptance under the Java Community Process as JSR-241, The Groovy Programming Language. When finalized, this will make Groovy the second official language for the J2SE platform. This is an exciting prospect, as a second language confirms J2SE as a true development platform and more than just the Java language. In this regard, it is possible Groovy is blazing a trail for other languages to follow.

Groovy resides under the Codehaus at http://groovy.codehaus.org. The language is well advanced but as of this writing is available only as a beta. The latest Groovy installation is available from the site. The site also provides extensive documentation with plenty of examples.

If you are keen to try Groovy, you might like to implement the Jython examples shown in this chapter using the Groovy language as an exercise. This exercise will help you determine which of the two scripting languages best suits your needs. Choosing between the two might be a dilemma, but it's nice to have such a good choice.



    Rapid J2EE Development. An Adaptive Foundation for Enterprise Applications
    Rapid J2EEв„ў Development: An Adaptive Foundation for Enterprise Applications
    ISBN: 0131472208
    EAN: 2147483647
    Year: 2005
    Pages: 159
    Authors: Alan Monnox

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net