A simple analogy by Fred Brooks illustrates the important difference between array languages such as APL and J, and “conventional” languages such as Fortran, BASIC, Pascal, etc. Suppose we have a box of apples from which we wish to select all of the good apples. Not wishing to do the task ourselves, we write a list of instructions to be carried out by a helper. The instructions corresponding to a conventional language might be expressed something like the following:
Select an apple from the box. If it is good, set it aside in some place reserved for the good apples; if it is not good, discard it. Select a second apple; if it is good put it in the reserved place, and if it is not good discard it. Continue in this manner until all the apples have been examined.
The instructions corresponding to an array language could be stated simply as follows:
Select all of the good apples.
The apples would still have to be examined individually, but the details are left to the helper (the computer) and don’t have to be specified by the programmer. Conventional languages are apple-by-apple languages, while array languages are all-the-apples-at-once languages.
Here are two simple examples to illustrate programming in APL and J. If X is a list of numbers, the APL statement
computes the mean of X, and may be read as follows: “The MEAN is the sum over (+/) the items of X divided by the number (ρ) of items in X.” As a second example, if N is a positive integer, then the J statement
computes the list of primes that are less than or equal to N. Although more formidable than the APL example, it may be read simply as “The list of primes is found by selecting those integers in the list x= 2, 3, …, N which do not appear in the multiplication table for numbers up to N.” For N equal to 0 or 1 the list Primes is empty.
The Computer History Museum has recently managed to recover the "lost" code for an early implementation of APL on an IBM /360. They have created an on-line exhibit examining APL and Ken Iverson. It contains an extensive account of the language and its creation as well as additional information on Iverson himself. There are also links to further resources. It is available here.