NetRexx, another approach for a programming language
Object-oriented and running on the JVM, this scripting language is original in its design, and even strange.
The REXX (REstructured eXtended eXecutor) language was created by Mike Colishaw in 1970 for IBM, and implemented
on the IBM 370. It was used as a scripting tool on OS/2. It was intended to provide a clear and structured syntax.
NetRexx is a new,
object oriented version which was written in 1997, and which compiles into
Java bytecode to run with the Java Virtual Machines.
The latest release date of 2013.
A king (rex in latin) card is sometimes used
to illustrate the language.
Why use NetRexx?
It is talked quite a few of NetRexx today. It is actually not widely used apart on IBM's environments.
REXX addressed to the novice user, rather than professional programmers. It could be used to scientific computing but these days it is largely supplanted by Julia and Python in this field .
It is intended to replace Java with a simplest syntax and was the first langage to be ported on the JVM beside Java.
It can make applets too, uses the Java's API.
It is a mean to use a same language for scripting and applications, but numerous other languages do the same. In fact, since its inception, it has been usual to port a language to the JVM (Jython, JRuby, etc...), which makes NetRexx useless for a practical use because it has less features.
Its main interest is to study a different approach in the design of a programming language, and the simplification in the syntax it brings.
Advanced control structures
The language combines the simplicity of the syntax with the complexity of constructs.
- It is an Object oriented scripting language, unlike Rexx. It supports inheritance and generics (which go misses).
- A method is terminated when another method begins, or at the end of the file. "Return" is used only to return a value.
- The body of a function is terminated by a blank line, that is perhaps unique to this language while Python is the only one to use indent as part of the syntax.
- The select case ... when ... then construct if the NetRexx equivalent of switch ... case, but more powerful. Since there is no value to compare with the various cases, the interest seems to be mainly in falling in a default case when no other case is matched.
- Block of statements are delimited by do ... end. A condition is added to create a loop.
The same do ... end construct replaces so severals sort of loops in other languages (for, while, until).
But here this is not really a simplification, if we add while to do, it would be simpler to just use while. - It is the same with the loop for construct, the word loop is redundant.
- String is the default type for variables.
- Fixed size array and associative array are the only two composite types, beside classes.
- A message is displaying in the console with the SAY reserved word while any other language use echo (coming from Bash) or print (from Basic).
NetRexx source may be either compiled into bytecode, or directly interpreted. In the first case it is compatible with the Java API and its classes.
Even if the language brings many simplifications that make writing a script faster, its design looks weird and had room for improvements. It is a powerful language, but which bring no unique features.
Sample code taken from the NetRexx manual...
Script waiting for an answer:
-- A script
loop label prompt forever
reply=ask
select
when reply.datatype('n') then say reply**3
when reply='Quit' then leave prompt
otherwise say 'eh?'
end
end prompt
say 'Done.'
Applet displaying Hello World:
class HelloApplet extends Applet
method init
resize(200, 40)
method paint(g=Graphics)
g.drawString("Hello world!", 50, 30)
The applet is loaded with this HTML code:
<applet code="HelloApplet.class" width=200 height=40> </applet>
See also...
- Scala a modern and popular language for scripting or to replace Java on the JVM.
- REXX Language Association. Association that host the source code of NetRexx now, given by IBM. Note that the association uses lowercases when the author wrote the name in all caps.
- The design of the REXX language. By Mike Collishaw.