NetRexx: A Blend of Java and Rexx- by Dirk Hamstra

New programming languages pop up every day. All languages come with their own set of features and quirks and many share one characteristic: they never make it into mainstream IT. Sun's Java, now in beta for OS/2, is a relatively new language. But in contrast to other languages, Java is going to make it big time.

I've changed my mind about Java in the last few months. Initially I thought Java was a language for creating small programs ("applets") for downloading and interpreting on various browsers. However, Java can also be used to create programs that can be uploaded and run on servers ("servlets"). Combine Java with JDBC (Java Database Connectivity), JOE (an object request broker) and a slew of products with coffee-related names and you have a full blown programming language with a cross-platform execution environment.

These features are not for free. Java is complex language. For OS/2 users, however, there is good news. From the IBM labs in Hursley, England, comes NetRexx. NetRexx is a new dialect of Rexx that provides access to all functions and features of Java using the Rexx syntax. In the remainder of this article I'll discuss both Java and NetRexx.

Java

Java is part of the Java family that includes JavaScript. Both languages share many characteristics with C and C++. Their syntax is comparable but the semantics differ. Java is a "com-terpreted" language. This means that Java is precompiled with pseudo-code (a.k.a P-code or bytecode). The P-code is then executed by an interpreter. This gives Java the benefits of a compiled language, like static binding, without requiring the presence of the source code at execution time. JavaScript on the other hand is completely interpreted. Bindings are dynamic and you need the source code at run time.

One of the major attractions of the Java family of products is the ability to run unmodified programs on different hardware and software platforms. Creating a cross platform execution environment is not a new idea. Look at Rexx. Rexx has been available to users of OS/2, MVS, AIX, NT, Amiga, and other operating systems for years. Programs developed on one platform can usually be executed on another. Other important features of Rexx are ease of use and a low learning curve.

NetRexx

The portability and efficiency features of Java and the ease of use of Rexx are combined in NetRexx, which is derived from Rexx and Java. NetRexx syntax is similar to Rexx, but some changes have been made to the Rexx Language. This makes NetRexx not fully upwardly compatible with Rexx. Here are some of the changes: Creating NetRexx programs can roughly be split in two steps. First write your code in Rexx, and second, generate Java P-code by running your code through the NetRexx translator. Programming in NetRexx offers a number of advantages over writing code in native Java. For example, storage allocation and reclamation are automatic in NetRexx. Java implements a variety of numeric and string types. NetRexx on the other hand implements all types in one class that follows the rules of Rexx strings.

For string manipulations NetRexx behaves like plain Rexx. Objects are used to handle non-strings. The following sample Customer program demonstrates what an object is in NetRexx, how it can be created, and how to define actions for the object.

/* Customer.nrx -- customer template  */
class Customer
     name           -- list of properties for this customer
     address
     phone
An object is created from a class description. The class statement, which names the class (Customer), is always the first statement. Java expects the filename to correspond to the class inside it. Thus, the program must be written in a file called Customer.nrx. For NetRexx programs, the default file extension is ".nrx". A list of properties of the class (name, address, phone) follows the class statement.

Actions that can be performed on the object are defined in the method section. For Customer, the methods Customer, change_address, and display have been defined.

/* Create a new customer */
method Customer (new_name, new_address, new_phone)
  -- the new customer has not been initialized yet, copy the
  -- parameter values to the object properties

     name = new_name
     address = new_address
     phone = new_phone

/* Change customers address */
method change_address(new_address) returns Customer
     address = new_address
     return this

/* Display customer information */
method display()
     say `Customer` name address phone
The Customer.nrx file is compiled into a class file called Customer.class by the NetRexxTranslator. Subsequently the Customer.class can be run in a Java environment.

To create a customer from the class definition, you would use a program similar to the following:

/* sampleCustomer.nrx -- instance of a customer */

aCustomer = Customer(Joe, aStreet, 552-3490)  -- create a customer
aCustomer.print                               -- display the customer information
aCustomer.update_address(anAvenue).print      -- update the address information and show the
                                              --new values
In summary, NetRexx combines the best features of Rexx and Java. The combination allows OS/2 users to benefit from the ease of programming in Rexx and the efficiency and portability of Java. The experimental version of NetRexx is available now on: http://www2.hursley.ibm.com/. To work with the current version you must install OS/2 with HPFS and the Java Development Kit for OS/2.
Dirk Hamstra is active as an OO-consultant with RCG IT and he is an independent partner of DOOSYS IT Consultants US, an international OO-consulting organization.

[Index]  [ Previous] - [Feedback] - [Next ]
Our Sponsors: [Prominic Technologies] [ScheduPerformance] [Shenandoah] [SPG] [Surf'nRexx]


This page is maintained by Falcon Networking. We welcome your suggestions.

Copyright © 1996 - Falcon Networking