MARTHA and LLAMA - APL Section
MARTHA-LLAMA logo

The APL Computer Language

In order to appreciate the full value of MARTHA and LLAMA, a few words about the APL language itself are in order.  APL was originated at IBM as a concise form of mathematical notation.  It became quite popular within the technical ranks of IBM, and a desire to make it machine executable resulted in the core of the computer language used today.  Drawing from conventional math notation, a special character set was used.  This required special terminals and printers, which was a hindrance to its acceptance and growth.  Despite this, it developed a devoted (but somewhat small) following in research laboratories around the world.  It also became popular for statistical and actuarial work at a number of large corporations.  It is still taught at a number of Universities, and is popular in Europe, Canada and Russia.

Up until the mid 1980s, most APL was run on large mainframe computers.  With the advent of personal computers, and an APL interpreter for them, it became possible to use programmable fonts and dot-matrix printers to deal with the character set problem.  With the advent of 32-bit architectures, it is now possible to run larger programs in less time on a basic PC than was ever possible on the best mainframes of yore.

APL has a number of key features that make it an efficient problem solving tool:

1)     APL programs are written using ‘functions’.  A function is a modular routine that can be executed in isolation, or it can be called by other functions (including itself).  This makes well-written code re-useable.  In this regard, APL has a lot in common with the ‘C’ programming language.  It also means that small functions that perform well-defined tasks become an extension to the language itself.  A function to calculate the characteristics of coupled microstrip transmission lines can later find itself called as an essential ingredient of several different microwave filter synthesis functions.  The utility of a function is frequently limited not by the intent of its original author, but only by the ingenuity of later users.  Of course, this only works if the functions are documented well enough that they can be understood by other users.

2)     APL is an array based language.  In most computer languages, vectors, matrices and higher order arrays must be handled on an element-by-element basis.  In APL, arrays are manipulated as arrays.  If two (equal-length) vectors, A and B need to be added, they are simply added: A+B without the need for loops, indices etc.  APL includes many powerful single-character operators to perform more complex manipulations of matrices and larger arrays, including transposition, rotation and inversion.

3)      APL is a ‘smart’ language.  It is smart enough to know how to handle large variables, so you never have to dimension arrays or allocate and de-allocate memory.  It is smart enough to know that 'A' is a character, 1.25 is a floating point number, 2 is an integer and (depending on its usage) 1 is a Boolean.  All numerical computations are automatically done in double precision.  This eliminates an enormous amount of programming overhead and debugging.

4)    The code is interpreted rather than compiled.  This is viewed as a major drawback by many, and can result in slightly slower execution.  However, it means that APL can be used as a ‘super-calculator’ for quick solutions of technical problems.  Operating in ‘immediate mode’, code typed on the screen is executed on the spot.  This is not only handy for small computations, but by testing the execution of more complicated code, the pieces of a function can be debugged as they are built up.  Rather than putting an entire function together, compiling and debugging after the fact, critical operations are checked ‘in process’.  The completed function frequently requires no further debugging.

Note that the slower execution of interpreted code is frequently used to dismiss APL out of hand for solving large problems.  Because it operates on arrays and performs operations like matrix inversion internally, well written APL can be surprisingly fast.  A large amount of the overhead of a language like BASIC results from re-interpreting code in loops.  Using the array-based structure of APL, loops can frequently be avoided altogether, resulting in fast execution.  As an example, a microstrip transmission line analysis program was translated from FORTRAN to APL, with all of the loops left intact.  This took almost a full minute to analyze a single pair of coupled lines on a 33 MHz 486 PC.  Converted to loopless APL, the execution time was reduced to 1.48 seconds.  Using ‘C’ only cut the time to just below a second.  In the mid 1980s, the same computation took over 5 minutes on a ten million dollar ‘high speed’ scientific mainframe.  With today’s faster PCs, sacrificing ease of use (and programming) for small increases in execution speed is false economy.  If a severe computational bottleneck is encountered, many APLs can call compiled code from C or FORTRAN.

APL Language Resources:  There is quite a lot of information about APL on the web.  The largest single repository is at the University of Waterloo in Canada:

http://www.math.uwaterloo.ca/APL_archives/Welcome.html

There is a FAQ (Frequently Asked Questions) that talks about the history of APL, different interpreters, books, etc.

Getting Started:  The first public domain release of MARTHA and LLAMA is designed to run using the old standard DOS APL originally developed by STSC Inc., and sold as APL*PLUS/PC.  STSC became Manugistics, and is now APL2000.  They no longer sell or support any form of DOS APL, but there is a free version called APLSE (for Special Edition).  This is equivalent to APL*PLUS/PC Ver. 10, and is available for download below.  APL*PLUS/PC Version 11 was the last commercial release, and added some features, especially for working with extended or expanded memory.  If you can find a dusty copy somewhere, or even just a set of manuals, it would be worth looking for.

APLSE comes with some documentation, but it doesn’t cover a number of useful “system” functions.  There was an earlier free package from STSC/Manugistics called PLUSDEMO that has a lot of good documentation, including areas not covered well by the APLSE.  If you are unfamiliar with APL and don’t have access to any old manuals, installing PLUSDEMO is highly recommended.  The file Intro_to_APL.pdf (237 kbytes) gives a brief introduction to APL and guide to the documentation contained in both APLSE and PLUSDEMO.  It also includes an APL keyboard map you can print out to help navigate the APL keyboard and special APL characters.  Here are the two program download files:

         APLSE.zip (309 kbytes)              PLUSDEMO.zip (342 kbytes)

There are notes in the LLAMA manual on setting up APL libraries (directories) and the like, but not on installing APLSE.  The LLAMA manual was also written before the newer Microsoft operating systems came along.  Getting APLSE running seamlessly under Windows 2000, NT or XP can be a little tricky, but it can be done.  The file “APLXP_SETUP.zip” (130 kbytes)  contains a number of auxiliary files and instructions on how to set things up for Windows XP.  The instructions and files for Windows NT are contained in “APLNT_SETUP.zip” (127 kbytes).  The same procedures used for Windows NT should work in Windows 2000, but the shortcut file may need to be created from scratch.  If someone creates a successful Windows 2000 installation and wants to share their files and/or procedure, we will be happy to add them to this web site.  Older versions of Windows use real DOS instead of a DOS emulator, and should work without any major difficulties.  There are reports that DOS based APL can be run in Windows Vista, but we don’t have any first hand information on how to do this or what features might not function properly.


Home page | Search | Comments and inquiries