Channels ▼

Jack Woehr

Dr. Dobb's Bloggers

Open ObjectRexx

June 29, 2008

The Programming Language Originally Known as REXX has migrated from being a mainframe scripting language to a full object-oriented language, Object Rexx, and has for some time now been open source: Open Object Rexx.

Object Rexx is a pure superset of Rexx, which latter, like Perl, started off as a scripting language whose only full-fledged data type is the character string. As Michael Cowlishaw, inventor of Rexx, told me in 1996:

"There's a lot of overlap [between Perl and Rexx]. Both languages are good, for example, for writing scripts for the Web. They are really quite different philosophies on how to design a language, both valid. Larry Wall's philosophy is to put anything into the language that anybody asks for ... My approach is the other way 'round, that is, don't put anything in unless it's really, really necessary, because then you end up with a really small language with few notations, and you make people happy for a different set of reasons."

Rexx originally appeared around 1979 on IBM mainframes running the VM operating system. It exhibits a line-oriented syntax:

foo = 1 + 2

where, as in TCL and some versions of Basic, variables spring into existence by being referenced or assigned. Statements are either assignments, or start with keywords, or failing both those, are interpreted as commands to the host environment.

That is, a line like

gnorf 1 2 3

(with gnorf not being found as a keyword or function and otherwise lacking the assignment operator =) is passed to the operating system as a command line whose result may later be obtained by the program.

Interesting Rexx features include queues, stacks, and content-addressable memory called "stem variables," wherein all the following

smith = "dink couple"
smith.john = "dentist"
smith.john.car = "1947 Hudson"
smith.mary = "U.S. senator"
smith.mary.car = "PT Cruiser"

are instantiations over all of which, in Object Rexx, one may iterate merely by knowing the stem ("smith").

Beyond that, Rexx exhibits expressions, keywords, and functions internal and external. Expressions work pretty much like you'd imagine from other modern languages. Keywords are idiosyncratic, some taking sub-keywords, and perform basic language tasks such as parsing the arguments to the interpreter invocation. Functions are, well, functions: many are internal to Rexx, some are external but more or less standard, and functions may be added ad infinitum by enterprising programmers via a call API, which allowed Rexx to become the dominant high-level language on the IBM VM operating system.

Rexx leapt from the mainframe and penetrated workstations and desktop computers via commercial implementations on the Amiga, OS/2, MS/DOS, Windows and AIX, while later open source implementations such as Regina brought Rexx to the rest of the world.

Enter Object Rexx

Object Rexx grandfathers in all of classic Rexx and extends the language by adding directives, classes, and member/method invocation. Directives, including declarations of classes, are introduced by double-colons. For instance,

::REQUIRES 'foo'

indicates to the interpreter that a file foo (with an appropriate extension which may vary from platform to platform) must be included before commencing interpretation.

::CLASS SomeClassName

introduces a class definition, and

::METHOD someMethod

introduces a method definition. Both ::CLASS and ::METHOD must appear after any procedural code in the file, including code that invokes the class and its methods. Invocation of the class is indicated textually by preceding the classname with a dot (.) and methods are indicated by tilde (~) as in

.SomeClassName~someMethod(anArg,anotherArg)

So far, so good, and unexceptional. The kicker, when comparing Object Rexx to, say, Java, is that class definitions are merely an extension of the underlying string data type. Thus classes may be added or redefined dynamically and algorithmically at runtime. This is more or less true nowadays of Perl objects, but Object Rexx got there first with incomparably better syntax than Perl will have until Perl 6 is complete, while Java is still not there and may never be, in view of the requirement for the Java compiler classes (not licensed for redistribution with an application) to be present in order to compile code.

One result of this ability to define classes on the fly is that Object Rexx is an easy-to-use scripting language suitable for (among any number of other uses) modeling new object-oriented languages.

Open Object Rexx downloadable documentation is extensive, elaborate and well written. If you don't know the language before you download, you will indeed know it after R'ing TFM.

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 


Video