NetRexx: A Blend of Java and Rexx | - by Dirk Hamstra |
ew 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.
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.
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 phoneAn 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 phoneThe 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 valuesIn 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.
-- Copyright © 1996 - Falcon Networking
Our Sponsors: [Prominic Technologies] [ScheduPerformance] [Shenandoah] [SPG] [Surf'nRexx]
This page is maintained by Falcon Networking. We welcome your suggestions.