An Alphabet of Computer Languages: APL
by Gary L. Ratliff Sr. <eronstuc@gmail.com>
This is to begin a series of articles on computer languages. As I mentioned in earlier articles one of my reasons for purchasing computers, in particular my SuperPET in 1981, was the ability to learn to program in many languages. And on this machine I was first introduced to the fascinating language which was invented in 1957 by Dr. Kenneth Iverson. Here it was a system of notation, which, due to employing a unique set of symbols, was able to generate very compact code. This language operates on the array as its basic element. And with this I learned that a 'sort', which I had written in Basic and which took nearly four pages of program code, was translated into a single line APL statement containing only 67 characters!!
For example, the problem of adding together two matrices (A and B), would be solved in Basic by a series of nested loops with FOR statements to read in the input and then add the result, would be solved by the rather simple statement: C ← A + B. This saving is increased when one learns that there are also simple symbols to allow matrix multiplication and matrix inversion. Studies have estimated that the amount of coding required in APL is about one tenth of that of required to code the algorithm in another computer language.
An interesting aside: there was a contest in New Jersey which was based on the success of the Donald Trump Apprentice series which offered un-employed computer programmers the opportunity to compete for a $40,000 per-year junior programming position. Here one of the first assignments was learning to program using APL. The text mentions that a total of some 27 persons were in the initial set of competitors.
Getting and Installing APLX
There are several versions of APL available for Linux. Like REALbasic these are proprietary systems. However, one of these is available free of charge for non-commercial use. Then, once one learns and appreciates the ease and power of APL, they may wish to acquire one of the commercial versions. These are available in formats for the i386 or 32 bit machines and also the 64 bit AMD and Intel systems. One of the reasons for going to a 64 bit system would be the almost unlimited size of arrays supported. Persons working with extremely large data sets have had to rely on piecemeal processing. The micorapl website notes that currently the 32 bit version only supports memory up to 4 gigs.
The APL we will be using in this article is the personal version of APL for Linux. Download the program from the following site using the download facilities of Firefox:
http://www.microapl.co.uk/apl/linux_pe_form.html
Soon a file will appear on your desktop, which will be a gzipped tar archive. This is the Linux version of ALPX. They also have versions for Windows and MAC. Much information of their offerings and additional features of these systems is available from the firm's website, which may be reached with the following link:
http://www.microapl.co.uk/apl/
There are two methods of installing this system: as a normal user, and as root. The path to the application is different based on which method you select. The fonts will not be installed if you install as a normal user. This makes using the root method of install more desirable; also the system would be made available to all users. Therefore, open a terminal, su to root and install the system using these commands:
Caveat: perform this only on a system you use for experimenting. Do not do this on your main install as you will then have a potentially unstable system.
su <enter password for root> cd /home/gary/Desktop gunzip aplx_linux_pe_11.tgz tar -xvf aplx_linux_pe11.tar cd APLXLinux1.1 ./setup.sh
During the setup script select the default for all questions. Also register and they will email you an activation code which you will use to run APLX. Now restart the system and you will notice that there is a menu item (as seen below) for APLX for Linux (Personal Edition), which when selected, will offer to load APLX.
You will, of course, need the activation code for the first run. The easiest method is to copy it from the email message and then paste it into the request window using CONTROL V. You will then receive a request to restart APLX and you will now have the screen with a CLEAR Workspace as seen below.
Mastering the keyboard and Learning APL
Now it will be a great help if you have before you the printed sheet which contains the locations of the various keys. One could print out such a sheet by performing a search in the Google search box of your Firefox browser for APL Keyboard Layout. The one I found of use for this version of APLX was found at:
http://www.wickensonline.co.uk/apl/union-large.png
You will be able to select from two different keyboard layouts from the Tools menu of the Workspace. The one I prefer is the Unified APL Keyboard. Clicking the Help menu item then, selecting Keyboard Layout. Now by clicking you can hide the layout behind the window containing your workspace and bring it up front if you forget the location of a key. Note that it is color coded and in the Unified keyboard many of the items you will need are obtained by first pressing the ALT key. While keying in the examples of the functions and operators from the text of the book, it will show you how to use and learn APL. Some will require a key from the other set you are not using. Simply call up that keyboard, enter the desired symbol, and then go back to the keyboard which you prefer. Keeping the keyboard in use hidden behind the APL screen will be a handy shortcut for switching keyboards as required.
I learned that I will be able to allow you to use the same method I used to learn APL some 27 years ago. I found a copy of one of the most useful tools for either learning APL in a classroom setting, or teaching the language to yourself: APL: an interactive approach by Gilman and Rose. So let us get into Firefox and enter this into the search window. We are using the Google search engine.
"APL: an interactive approach"
Soon a list of the search results will appear in your browser. Select the first one which should be: APL - An Interactive Approach-2nd Edition pg 1. This will be the text of the entire book. The control keys in the window on the left allow you to go forward and back one page, increase or decrease the darkness level of the text and increase or decrease the text size.
From the initial page, the up arrow will take you to a list of books and articles you may wish to explore. The right arrow will take you to the next page in the text. Once you are beyond the first page a left arrow will appear which will allow you to go back one page. As you work your way through the text, you may not wish to use the one page at a time method to reach the location at which you stopped. Placing the cursor within the number window and entering a page number and then clicking the GO item will take you directly to that page.
Next, if like me your eyesight is getting worse, you may wish to increase the text size so that you may read the pages without wearing your glasses. The circle with the + will accomplish this just keep clicking till the test size is as large as you need. The circle with the - upon it will reduce the text size in similar increments. The next three items, which appear as contrast figures, will increase the darkness of the displayed text or decrease it if the white contrast key is selected. Finally, we have covered all the controls except the three arrows on the bottom. Clicking the downward pointing arrow will rotate the entire text page 180°. In a similar fashion the other two arrows will rotate it 90° in the selected direction.
Now your PCLINUX OS System is well equipped to allow you to easily teach your self APL. Simply place your Workspace in one screen and the text of the book in another. Then by reading the text and moving to your Workspace you will be interactively learning APL.
This has been shown to be the fastest method. Also by teaching yourself you are not held back by slower learning classmates. From the work space you receive instant feedback. As the text of the book has the correct answers you know if you have keyed in the item correctly.
Set a goal to complete a chapter per day, or a chapter per week, depending upon the amount of free time you have to devote to this and soon you will be the master of a fascinating computer language, which, by being around since the very beginning days of computing, has stood the test of time. If you have programmed in other languages you will marvel at the simplicity and power this language provides.
Setting up the APLX documentation
The above method will allow you to explore and learn APL. However, the system you downloaded has much more to offer. The Help menu item will allow you to read sections on the system while within your APL workspace. The system comes equipped with several book sized documents which are in the ubiquitous format of pdf files. PCLINUXOS provides the kpdf program which easily allows you to view this type of file. However, we first must point this to the file location. To do this just get to a terminal. Now locate the documentation provided with APLX by issuing this command and then set kpdf to point to any one of the displayed pdf files.
cd /usr/local/aplxpe/manuals ls
This will produce a list of the three pdf files which are included in the documentation provided with this system.
kpdf APLX <tab>
This will allow you to select from the available files pressing S and then the tab key will expand your selection to be: APLX Standalone Applications.pdf. This is only a 13 page document and will load the quickest of this selection.
Now, when you use a terminal to again use kpdf and then select OPEN, the other pdf files which were found will also be listed as candidates for viewing and and may easily be selected.
There are also provided several workspaces with pre-written functions and operators which you may use. To locate these select from the File Menu the Open command. This will cause a Look-in window to appear, pointing to your home directory. Use the blue up arrow to move it till it points to: /usr/local/aplxpe/ws by clicking each item in turn until the list of the provided workspaces appears. By selecting DISPLAY we learn that this is now obsolete. Now you are given a clue to get help in using this workspace. Do not try to type in this command simply select it with the mouse pointer and press the Enter key. The text will move to the input area and the HELP function will be executed. The text of other commands given in these work spaces may be executed in a similar manner.
You now have the ability to explore and learn the system by reading the documentation provided and also the ability to explore and use the many workspaces provided with this system.
As you may have inferred, I have been dealing with MicroAPL Ltd. for several years I have always found them to be most cooperative in getting their system to function on my various computers over the years. Also I would like to express my appreciation to Richard Nabavi of Microapl for being willing to answer many questions I have had in my dealings with this version of APL.
Next time we will explore the commercial version of this system.