|NetRexx||- by Tejaswi Kasturi|
IBM's NetRexx is a new portable, programming language designed for use in a networked environment, whether over the Internet or on an intranet.
"Great," you say ,"yet another language purporting to be 'network-savvy'. Yet another language to learn and another set of platform-specific runtime modules to deal with."
NetRexx, however, is not a completely new language. It is a direct descendent of REXX, OS/2's built-in scripting language, and Sun's Java, the de facto standard for portable programming over the Internet. NetRexx leverages REXX's ease of use and Java's portability to create a very effective language for all programmers wishing to create networked programs.
How it works
NetRexx code is translated into Java code by the NetRexx "compiler". The Java code is then compiled into Java byte-code by the Java compiler from the Java development kit. Even the NetRexx runtimes and compiler are written in Java for maximum portability. In order to run a NetRexx application, you just need a Java runtime and the small (75 K) NetRexx runtime class package.
NetRexx code can import and use any classes written in Java or NetRexx, and Java code can see and use NetRexx classes. To the programmer, NetRexx and Java classes are perfectly interchangeable. This interchangeability comes from the fact that the NetRexx compiler merely translates NetRexx code into completely acceptable Java code, which cannot be distinguished from Java code written by hand.
Retrieval and Installation
The NetRexx Development Kit is freely downloadable from IBM's NetRexx page at http://www2.hursley.ibm.com/netrexx/. The development kit can be used on any platform for which there is a Java 1.0 development kit available. Most major platforms, including OS/2, Windows 3.1/95/NT, MacOS, and most Unixes, currently have a Java development kit, and hence are supported by NetRexx.
NetRexx's installation is straightforward, but not automated. Files need to be unpacked and put into the correct directories manually, and (for OS/2) the CONFIG.SYS needs to be edited. This gives the impression of a technology demonstration, such as Sun's Java Development Kit, rather than a finished application.
NetRexx is intended for programmers who wish to write Java applets and applications using a less difficult language, such as REXX. NetRexx inherits much of its ease of use from REXX and Object REXX, but is not fully compatible with those languages. For example, where Object REXX uses the tilde ("~") to separate the object name and its method, NetRexx uses the period (".") to retain familiarity for Java programmers. For example, here are equivalent method calls in Object REXX, NetRexx, and Java:
However, most of the useful functions in REXX have been ported over to NetRexx. REXX has traditionally been very strong in string handling capabilities, and NetRexx inherits much of its power through the use of a specialized String class, called Rexx. Conventional Strings, characters, and numbers are seamlessly converted to the Rexx string class, on which operations are performed, and the results are returned in the appropriate format. The parse instruction, one of the most powerful REXX functions, finds a happy home in the NetRexx world. From the NetRexx Language Definition, "The parse instruction is used to assign characters (from a string) to one or more variables according to [defined] rules and templates." This is very useful for reading information from data files and over the network. Although such functionality exists in a rudimentary form in Java, through the StringTokenizer class, that class is far more difficult to use than the very elegant parse instruction.
- Object REXX
NetRexx allows the programmer to deal with the algorithms rather than having to deal with the underlying type declarations and conversions required to perform the task at hand. Variable type declarations are not required in NetRexx, unlike in Java, allowing rapid application development, with the cost of making code more difficult to understand if not written properly. Coding in Java requires strict attention to code declarations, which quickly becomes tedious. Coding in NetRexx is far more enjoyable, since the NetRexx compiler is intelligent enough to "figure out" many of the constructs which need to be explicitly spelled out for the Java compiler.
However, all is not happy in the land of NetRexx. NetRexx uses the runtime classes by default, which can add 75K to the size of any program. However, the use of the runtime classes can be disabled through the use of the "options binary" instruction, or by defining the class to be "binary". This causes only primitive types, those types built into Java, such as "int", "String", and "char", to be used instead of converting all values through the "Rexx" string class. This also requires extra vigilance on the part of the programmer, since he/she must make sure that there are no type conversions (implicit or explicit) to the Rexx class, and also must explicitly define the type of all string variables to prevent them from automatically being assigned a type of Rexx. If there are any references to the Rexx class, then the runtime classes will be loaded, even if "binary" is specified. If the runtime is used, it is not likely that all of it is used by any given class, but even the use of the Rexx class by itself will add at least 35K to the size of the program. The Tablet class is an example of a NetRexx applet which does not use the runtime classes, and can be found at http://www2.hursley.ibm.com/netrexx/tablet.htm.
Furthermore, the NetRexx compiler slows down the compile process very significantly, doubling the time for compilation compared to handwritten Java code because of the initial translation time.
Finally, classes using the NetRexx runtime may require a large number of type conversions, between primitive types and the Rexx class, which can slow down the execution of large programs. Since Java applications are already fairly slow, even the small increase in execution time caused by NetRexx may not be worth it. Writing performance-oriented classes in Java and less performance oriented code in NetRexx, within a single project, may be the best solution, analogous to how many C functions are coded in Assembler for speed.
Overall, NetRexx is a very easy-to-use and powerful language for use in network environments where portability is key. Although the use of the language needs to be examined on a case-by-case basis, due to speed concerns, IBM seems to have another winner on their hands.
download from the IBM (ZIP, 580k)
Tejaswi Kasturi is a Founding Partner in charge of web site/intranet design and system administration at 4th Millennium Consulting Group, an Internet strategy consulting and web site/intranet design firm. In his spare time, Tej uses OS/2 Warp 4 to maintain the OS/2 Internet Resources site, an OS/2 e-Zine! Site of the Week.
[Our Sponsor: BMT Micro - Registration site for the best OS/2 shareware applications available.]
This page is maintained by Falcon Networking. We welcome your suggestions.
Copyright © 1997 - Falcon Networking