Groovy programming on IBM i

Groovy programs, based on the Java language and bytecodes, can run on IBM i. The built-in AIX support, PASE, allows AS/400 shops to take advantage of the new Web programming language that boasts brevity among its advantages. With a short learning curve for those with Java experience, Groovy makes modern programming features available to IBM i.


Andrew Borts

Some people keep telling me that the IBM i is falling behind with development technologies – but honestly, that's far from the truth. There's an emerging base of languages that allow the users to keep their existing skills, and merge them into a new fusion of language and technologies that are compatible with the iSeries through the built-in AIX support in the operating system (PASE environment). Whether you know it as "Q-Shell" or...

PASE -- either way, you're already using a platform capable of far more then you may realize (we're running our PHP suite through this environment).

Groovy has a short but sweet history, using the Java language as a superset, the language actually merges many technologies and syntaxes that people are familiar with. With this familiarity, people can become proficient rather quickly in these new "fusion" languages: Ruby, Ruby on Rails, and now Groovy (based on the Java language and bytecodes).

Groovy has the advantage of being based on Java, whereas Ruby is based on Perl, and small talk languages. One of the advantages of Groovy is that it compiles directly into Java bytecode, instead of being an interpreted language. Groovy on Rails (or "Grails") is a Web application framework that utilizes the Ajax methodology of using asynchronous Javascript to give Web applications a more "PC" application feel to them.

Groovy gives the ability to make programming far more compact then Java, simplifying the syntax to describe things. Five to seven lines of application could exist as one line of application – for example (from the Groovy Wiki page)


public class StdJava
{
 public static void main(String argv[])
 {
 for (String it : new String [] {"Rod", "Carlos", "Chris"})
  if (it.length() <= 4)
  System.out.println(it);
 }
}

The above code is rather compact – but compare it to the Groovy code for the same thing:


["Rod", "Carlos", "Chris"].findAll{it.size() <= 4}.each{println it}

While it complicates things to learn a new language, I argue that for the programmer on the go, one line is great!

The reasons Groovy should be in your programming language arsenal include

  • Dynamic typing – meaning that the syntax checking is looser allowing for faster functioning code. It is dynamic because a majority of the checking happens at run time, not compile time.
  • Overloading – the ability to make subroutines/functions do more then one task, simply by adding a field to the called parameters.
  • Native support for regular expressions – giving a powerful search and replace capability within strings. One line of code could do what would take arrays and special string handling in the "old days." Regular expressions have been found in languages such as Pearl, PHP, and Ruby.
  • 100% Java compatible – as a matter of trivia, you can change the extension of your .java programs to .groovy and they will compile into java bytecode – same as before!

The Grails Framework – in addition to the above aspects, Grails gives the following advantages:

  • Supports CRUD scaffolding – so you get immediate access to create, read, update and delete by programming "def scaffold = true" – imagine deploying an application to modify a database within three lines of code.
  • Provides a high productivity web framework for the Java platform
  • Re-use open Java technologies within a consistent interface.
  • Sample applications are provided, and are readily available over the internet.
  • No XML configuration required! (which while externalizing your static information, can slow ya down. Note: Don't stop externalizing static information! (Please.)

Groovy has another distinct advantage of also making people think of the 59th Street Bridge song by Simon & Garfunkel.

I don't know about you, but I'm now "feeling Groovy" about our Java future!

ABOUT THE AUTHOR: Andrew Borts is Webmaster at United Auto Insurance Group in North Miami, Fla. He is a frequent speaker at COMMON and is past president of The Southern National Users Group, an iSeries-AS/400 user group based in Deerfield Beach, Fla.

This was first published in June 2009

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close