How do you design a programming language to be powerful yet still easy to use? Rexx offers one example. This article describes how Rexx reconciles these two seemingly contradictory goals.
History of Rexx programming language
Several decades ago, computers were shifting from batch to interactive processing. Developers required a scripting or "glue" language to tie systems together. The tool needed to do everything from supporting application development to issuing operating system commands to functioning as a macro language.
Mike Cowlishaw, IBM Fellow, created a solution in a language he named Rexx. It is widely considered the first general-purpose scripting language.
Rexx was so easy to use and powerful that it quickly permeated all of IBM's software. Today, Rexx is the bundled scripting language on all of IBM's commercial operating systems (z/OS, z/VM, z/VSE, and IBM i). It's no surprise that in the 1990s, IBM bundled Rexx with PC-DOS and then OS/2. Rexx popped up in Windows in the XP Resource Kit (before Microsoft decided to lock in customers with its proprietary scripting languages, VBScript and PowerShell). Rexx also emerged as the scripting language for the popular Amiga PC.
Open source Rexx
With Rexx spreading across platforms, standardization was needed. The American National Standards Institute (ANSI) stepped forward in 1996.
That opened the floodgates. Open source Rexx interpreters started appearing. Today, more than a half dozen interpreters run on every imaginable platform and operating system, along with many open source tools.
Two Rexx variants deserve mention. Open Object Rexx is a compatible superset of procedural or "classic" Rexx. ooRexx is message-based and provides all the classes, objects, and methods one could hope for. For example, it supports multiple inheritance and mixin classes.
Paralleling the rise in Java's popularity, Mike Cowlishaw invented NetRexx. NetRexx is a Rexx variant that fully integrates with everything Java (including its object model) and runs on the Java virtual machine.
ooRexx went open source in 2004; NetRexx in 2011. Today the Rexx Language Association enhances and supports both products. The RexxLA also supports Regina, the most popular classic Rexx interpreter, and BSF4ooRexx, a tool that fully integrates ooRexx with Java. Everything Rexx is open source.
So, back to the initial conundrum. How does a programming language combine power with ease of use?
One part of the solution is a layered architecture. Operators and a minimal set of instructions form the core of the classic Rexx language:
Surrounding the core are the language's 70-odd built-in functions:
- String manipulation
Additional power is added in the form of external function libraries. You can invoke external functions from within Rexx programs as if they were built in. Simply make them accessible by proper reference at the top of your script.
Function libraries are available for everything: GUIs, databases, web services, OS services, system commands, graphics, access methods, advanced math, display control, and more. The result is a highly-capable open source ecosystem.
Finally, recall that Open Object Rexx is a superset of classic Rexx. So you could use procedural Rexx and then transition your skills and code to object programming by moving to ooRexx. In a sense, ooRexx is yet another Rexx extension, this time into object-oriented programming.
Rexx is human-oriented language
Rexx glues all its instructions, functions, and external libraries together in a consistent, dead-simple syntax. It doesn't rely on special characters, arcane syntax, or reserved words. It's case-insensitive and free-form.
This approach shifts the burden of programming from programmer to machine to the greatest degree possible. The result is a comparatively easy language to learn, code, remember, and maintain. Rexx is intended as a human-oriented language.
Rexx implements the principle of least astonishment, the idea that systems should work in ways that people assume or expect. For example, Rexx's default decimal arithmetic—with precision you control—means you aren't surprised by rounding errors.
Another example: All variables contain strings. If the strings represent valid numbers, one can perform arithmetic operations with them. This simple concept of dynamic typing makes all data visible and simplifies tracing and debugging.
Rexx capitalizes on the advantages of interpreters to simplify program development. Tracing facilities allow developers to direct and witness program execution in various ways. For example, one can single-step through code, inspect variable values, change them during execution, and more.
Rexx also raises common error conditions that the programmer can easily trap. This feature makes for more standardized, reliable code.
Rexx's approach to arrays (or tables) is a good example of how it combines simplicity with power.
Like all Rexx variables, you don't have to declare them in advance. They automatically expand to the size of available memory. This feature relieves programmers of the burden of memory management.
To form an array, a so-called compound variable stitches together a stem variable with one or more subscripts, as in these examples:
Subscripts can represent numeric values, as you may be accustomed to in standard table processing.
Alternatively, they can contain strings. String subscripts allow you to build associative arrays using the same simple syntax as common tables. Some refer to associative arrays as key-value pairs or content addressable memory. Allowing array contents to be accessed by arbitrary strings rather than simply numeric values opens up an entirely new world of algorithmic solutions.
With this flexible but consistent syntax, you can build almost any data structure: Lists, two- or three- or n-dimensional tables, key-value pairs, balanced trees, unbalanced trees, dense tables, sparse tables, records, rows, and more.
The beauty is in simplicity. It's all based on the notion of compound variables.
In the future, I'll walk through some Rexx program examples. One real-world example will show how a short script using associative arrays reduced the runtime of a legacy program from several hours down to less than a minute.
You can join the Rexx Language Association for free. For free Rexx downloads, tools, tutorials, and more, visit RexxInfo.org.