The Codesmith's Library
Written by Carsten Whimster
The Codesmith's Library
In The Codesmith's Library, I focus on development books and materials. I have written this column from the point of view of an intermediate PM C programmer and intermediate REXX programmer. Pick up whichever book strikes your fancy, and join the growing group of people following our PM programming columns. I have already reviewed a number of beginner's books, and will try to concentrate a bit more on intermediate techniques and special topics from now on.
Please send me your comments and thoughts so that I can make this column what you want it to be. I read and respond to all mail.
Programming In REXX is an introductory book from the J. Ranade Series of mini- and mainframe computer books. Of course, this particular book is not about minicomputers or mainframes, but rather about learning portable, standard REXX.
I have added a "Book Errors" page to the site, and put a link directly in the column of each issue, to let you see these errors and to let you judge for yourself how serious they are. If anyone has found any errors in this or any other books, please pass them on, and we can keep track of them here. A central site to check for errors would be very beneficial, I feel, so hopefully we can do this thing together.
I have personally started a Web page called "The OS/2 API Project". It is accessible from my normal homepage listed on my author page. The purpose of this page is to promote The OS/2 API Project, and to give it a temporary home. Eventually I hope to have this page on the EDM/2 site, but until we get more space, it'll stay where it is. The OS/2 API Project is a documentation project which eventually aims at covering the whole available OS/2 API, from Dev functions to Wps functions, from messages to structures, and from define's to include's. Please access the site to find more information. Also look for the upcoming announcement in both EDM/2 and on various comp.os.os2.* newsgroups. So far, I have two other contributors, but with three people it will take a long time to come together, so we need all able- handed people to type up their favorite APIs for this project.
Programming In REXX
Here is a book which has a distinct taste of a bygone era. Not that it is out-of-date, which it is not, but rather that the author treats the reader with respect, and gives intelligent explanations aimed at intelligent people. This is rather refreshing given the current tendency for books to insinuate that the reader is somehow of inferior intellect, often starting with the title of the book. The chapters are as follows:
Chapter one briefly describes what REXX is and what it is not. REXX is described as being a "personal" programming language. It is fun and easy, but not for heavy-duty tasks. A history of REXX is presented, and a brief sample program used to describe the feel of REXX. The dynamic memory management is outlined, and arrays (stem variables) and character string handling is touched upon. The fact that the API can used within applications in noted, and the advantages of having many different applications all use the same internal language are stated. Cowlishaw's The REXX Language is mentioned, and the relative positioning of the two books is explained. Finally, the standardization process of REXX is touched lightly on, and some portability issues discussed. The book assumes that you have a copy of REXX to work with throughtout the book, which should be a safe assumption for Warpers. For OS/2 2.1 users, make sure that you chose to install REXX.
Chapter two is an overview of REXX, and briefly introduces most of REXX's more obvious features, especially those which differ noticeably from other languages, such as the string handling, stem arrays/variables, variable initialization and (lack of) declaration. Also mentioned are the way procedures can hide variables, how to communicate with the external environment, and some common control structures.
In chapter three, we are introduced to the structure and syntax of REXX programs. This is accomplished through a more detailed description of REXX than you will find anywhere else, bar Cowlishaw's own The REXX Language. The language is broken down completely into tokens, built back up through clauses, instructions and commands. Control structures like IF are treated in-depth, due to the multiple-clause construction. Symbols, operators, special characters and invalid characters are all described. The various number formats are listed, including integer, floating point, decimal, hexadecimal, and binary formats. The basic equivalence of these types is carefully explained, in accordance with REXX's slightly unusual way of handling numbers. All of these explanations are accompanied by very detailed and enlightening examples designed specifically to highlight the feature being discussed while not containing any other confusing material. This is great to see when you are used to spending real time dissecting an example intended to illustrate the last twenty concepts discussed. The chapter wraps up with a discussion of operators and variables.
And so forth. Chapter four discusses the various control structures in detail, including IF, SELECT, DO, SIGNAL, and the many variants of each. One thing that makes this book very different than most introductory books, and more like books such as The C Programming Language, is the depth with which even very easy subjects are treated. When the author discusses the IF statement, he not only lists several different normal ways to use it, but also some more esoteric ways, and even a few ways that look correct but are not. Chapter five similarly discusses subroutines and functions and goes into some detail on various convolutions of the parameter passing mechanism, as well as variable scope.
Chapter six decribes, briefly, the common ways of communicating with the external environment, but even here, the book manages to one-up most other books, and discusses the fact that this external environment may well be an application program, rather than the more usual commandline environment. Due to the fact that this book stays environment neutral, there isn't a whole lot to say here though, so this is a short chapter. Chapter seven is the first chapter to have larger code snippets, and uses these to describe the string manipulation functions built in to REXX. This is accomplished through a mail parsing function, and a short implementation of the ELIZA program, an AI conversational program.
Chapter eight covers the PARSE instruction, and surprisingly does so in depth again. One would think that with the thoroughness of the previous chapters, the author would rest on his laurels here and there, but apparently not. Patterns are discussed as part of this treatise. Chapter nine covers I/O, and the various built-in functions that REXX has to support this. In REXX you don't have to open or close a file, but most actual implementations let you do this through some extensions to the language. The functions SAY and PULL are explained, as are CHARS(), LINES(), LINEIN(). LINEOUT(), CHARIN(), and CHAROUT().
Chapter ten is all about the external data queue. This is a potentially confusing subject, since it is a feature that doesn't exist in other languages. This is all described extremely well, though, and various gotchas are detailed. One such gotcha is the fact that there is one queue for all the REXX programs. I did not know this. The queue and stack paradigms are both explained. This external data queue apparently has its roots in VM/CMS where one such queue existed for the whole system to use, ie. REXX and other languages as well.
Chapter eleven discusses the important issue of exception handling. A good introductory discussion of exceptions can be found here, complete with the reasoning behind the subject. Both enabling and disabling these exceptions is possible, and sometimes the default is not what you need.
Chapter twelve treats us to a discourse on the INTERPRET instruction, as the chapter title so ably lets us know. INTERPRET is an instruction whose capabilities are unmatched by most other languages, with the notable exceptions of Lisp and Scheme. It enables the program to build up a string during execution, and then to execute it, as if it had been coded beforehand along with the rest of the program. Almost like self-modifying code, but not quite. The first example is of a 14-line program which allows you to type REXX instructions at a commandline, and have them executed. How many lines of C or Modula-3 or Java would that take? Lots! You might wonder if this is genuinely useful. If you want to see an opinion, ask a Lisp programmer why she does not use a different language! If you want to see an explanation without the opinions, read this book.
REXX arithmetic is all over the next chapter. The extended precision of REXX is rather unsual, as is the fact that for routine math, REXX isn't all that efficient. Be sure that you have a good reason for using REXX if you need lots of math! You could also write a REXX-callable DLL, and stash the more computationally intensive functionality in it instead. REXX also has a formatting function for numbers, FORMAT(). The various trig functions and the more commonplace math functions can also be found here.
Tracing and Debugging is the title of chapter fourteen. There are various options to the TRACE call, among which are F, E, and C. Interactive tracing is also possible, and you can read all about it here.
Finally, there are two appendices. Appendix A covers the REXX instructions, and is a short REXX reference. It has summary, arguments, and notes sections for each instruction, and appendix B has the same for the built-in functions.
This month's book is a cut above most other books I review, quality-wise. The editing, the format, the hard-cover, and the general tone of voice all cater to intellligent professionals who just don't happen to know REXX. You won't find any hint of superiority in this book, but just good solid explanations, good recommendations, and a step-by-step description of the language. Note that this book is very much a description of the language, and not a "how to program in REXX" book. Each feature of the language is clearly demonstrated, but there is no discussion of general programming principles.
Style-wise, Programming in REXX is very much like books such as The C Programming Language, and Modula-3, albeit with a touch less humour than the former. It has a distinct gentlemanly approach to the subject, rather than the "you are dumb, but we will teach you anyway" tone of voice that is so common now. It is very thorough, and is almost detailed enough to go as a language definition, from a learning perspective. This is not the intent of the book, however, as the author clearly states.
If you are familiar with modern programming practices and at least one modern language, this is a great book for learning REXX. It has enough detail that it can be used to clear up all but the most esoteric language points as well. If, however, you have never programmed before, and you are not familiar with modern programming concepts, then I would suggest getting one of the other REXX books I have reviewed. I like this book very much, and give it a solid A. The only caveat for OS/2 programmers is that the book covers standard REXX, but not any specific implementations.
Programming in REXX, Daney
Our Bookstore has reviews and links to Amazon for all books we have reviewed in the past, as well as several books waiting to be reviewed, and others which we recommend.