The point here is, we can stand on the shoulders of others. The more "componentized" these libraries are (for example, using JavaBeans signatures and events), the easier the use and integration is. On the subject of JavaBeans, the NetRexx
properties indirect statement generates getter and setter methods for all these properties something that Java developers depend on an IDE to generate or must write by hand. (While many NetRexx developers use editors, there is a NetRexx Eclipse mode that fills in the need for and IDE, and JEdit also has a very usable NetRexx mode.)
The clear separation between the language and library layers makes it possible to have a lot of options for user interface technology. All user interface technology that works with the JVM also works from NetRexx (including AWT, Swing, or JavaFX), as well as server-based technology (such as servlets, Struts, JSP, or JS)F. Some years ago, I even wrote a Web front-end with Flex with a Tomcat and NetRexx server back-end: Just think about the burning hoops you'd have to jump through to do that in another language.
Intuitive constructs such as
loop … end and
select … when … otherwise … end require no explanation. In parameter declarations, the local variable comes first, followed by and equal sign and the type of the variable. When the equal sign and type are omitted, they are assumed to be type
Rexx. A method declares a return type whenever it does not return
Rexx. This makes for a very relaxed definition of methods. The equal sign can also be used to compare a variable to a type; once you are used to that, it is very natural and you just use it as you would in English.
Runtime: The Rexx Data Type
Rexx (Java integration is such that nothing precludes you from using this from a Java language program) is the historical Rexx invention of having one type for strings and arbitrary precision numbers. It resides in the runtime package netrexx.lang, which is automatically imported for every program so you don't have to think about it (although it requires explicit import if you're calling NetRexx from Java).
String comparison is caseless and humanized in the sense that leading and trailing spaces are ignored. If you want strict comparison, the
== operator can be used: It is required if you want to write classes that are not dependent on the NetRexx runtime JAR.
New Features in Version 3.02
After JRE-only compilation was introduced in version 3.01 in 2012 (before that, NetRexx required a JDK for compilation), ease-of-use was addressed in version 3.02, which will be posted to netrexx.org around the time this article appears. New is the closer integration between the
Rexx type and the Java Collections Framework.
Where we had to cast a lot in previous versions, and did not have a natural order for elements of type
Rexx, these are now recognized and fitted for cast-less operation. We have gone from:
class RexxComparator implements Comparator,Serializable method RexxComparator method compare(i1=Object, i2=Object) returns int i = Rexx i1.toString() j = Rexx i2.toString() if i < j then return -1 if i > j then return +1 else return 0 t = TreeMap(RexxComparator()) i = t.keySet.iterator loop while i.hasNext r = Rexx i.next() end
t = TreeMap() t.put('foo','bar') t.put('baz','frob') i = t.keySet.iterator loop while i.hasNext r = i.next() end
Here, the keys are automatically put in the order of the now built-in comparator, and variable
r will be of type
Rexx. So, when getting elements out of the collection, no cast to
Rexx is necessary.
This is generic handling without the syntax. All
Rexx type container facilities (the associative "indexed strings" functionality) is usable from the elements in a collection, as are the NetRexx string methods.
Also, to ease integration in products that need on-the-fly compilation or interpretation of a string of code, an API was added to the existing, file-based compiler API. It enables program execution of a string containing the source, as in:
import org.netrexx. /* NetRexx compile from string example */ programstring = "say 'hello there via NetRexxC'" NetRexxC.main("myprogram",programstring)
d2b() enable conversion of binary strings to decimal, and decimal strings to binary. For example:
'01110'.b2d == 14 '10000001'.b2d == 129 '111110000001'.b2d == 3969 '1111111110000001'.b2d == 65409 '1100011011110000'.b2d == 50928 '129'.d2b == 10000001 '129'.d2b(1) == 1 '129'.d2b(8) == 10000001 '127'.d2b(12) == 000001111111 '129'.d2b(16) == 0000000010000001
Rexx type can now be subclassed, a long-standing wish of our user base.
NetRexx is written entirely in NetRexx. Other examples can be found at rosettacode.org, which catalogs various algorithms and puzzles with equivalent implementations written in numerous languages. The examples are also included in the NetRexx distribution, as are others that show nearly every aspect of the use of NetRexx in application software, including all the IBM NetRexx Redbook example code. I expect these examples will convince you that NetRexx is one of the most original and productive alternatives to Java on the JVM.
René Vincent Jansen is the current president of the Rexx Language Association; he was a systems programmer for decades and now manages technical teams in infrastructure and application projects. He likes everything that just works.