# APL

APL denotes both a programming language and a programming system. Its name simply abbreviates the title of [a2], which presents the earliest version of APL as a language, i.e. the very concise mathematical Iverson notation. The first available APL system was IBM's APL $ \setminus $
360 (1966). It became soon popular, mainly because it was an interactive system designed to be used conversationally at typewriter terminals. It is strongly based on the Iverson notation without taking over all its features. APL exists in many dialects and versions, and most of them are extensions to APL $ \setminus $
360 [a1].

APL is mainly a functional language, although it has also some imperative features. It is actually an array processing language, for all its non-trivial data structures are arrays and all its primitive functions and operators act on arrays. For the same reason, APL can also be considered a parallel language. The arrays in APL can be of any dimension and of variable size. However, in most dialects they have to be homogeneous and simple. These limitations, together with the lack of pointers, make it difficult to implement non-linear data structures (e.g. trees, graphs) in APL. It has no block structure, no explicit types and no explicit control structures. Loops can only be constructed by means of goto statements and should be avoided. Programs in APL are user-defined functions. All this makes programming in APL quite different from programming in imperative languages like FORTRAN, Pascal or C [a4]. Each of the many primitive functions has an APL character as its name. At first sight, the APL character set and its semantics look strange, but actually they reflect a wise design. Another characteristic of APL is that compound statements are strictly executed from right to left. This means that no hierarchy among operations and much less parentheses are necessary. The following two compound statements illustrate some of the spirit of APL:

$$ SUM \leftarrow + \setminus B \leftarrow 0 \ 4 { } ^ {-} 6 \ 8 < 7 \ 1 { } ^ {-} 2 \ 9.9 $$

$$ D \leftarrow { \mathop{\rm DIAMETER} } { \mathop{\rm CONVEX} } { \mathop{\rm POLYGON} } X $$

In the first example, two vectors are compared elementwise, resulting in a binary vector $ B $ of the same length. Then the elements of $ B $ are added and the result ( $ = 3 $) is assigned to $ SUM $. In the second example, the variable $ X $ is supposed to contain an array representing a sequence of points. The user-defined functions $ { \mathop{\rm DIAMETER} } $, $ { \mathop{\rm CONVEX} } $ and $ { \mathop{\rm POLYGON} } $ are applied successively, and the resulting diameter is assigned to the variable $ D $.

APL code is normally interpreted, not compiled. After a line has been entered, it is immediately interpreted and executed. This "desk calculator" property of APL enables efficient debugging. The implementation of algorithms in APL, often just for the purpose of rapid prototyping, is typically very fast. A further key element of the APL system are its work spaces, i.e. a simple mechanism for storing instances of variables and user-defined functions.

Two influential followers of APL are APL2 (IBM, 1984) and J (Iverson and collaborator's, 1990) [a1]. APL2 includes heterogeneous and nested arrays, whose absence in APL $ \setminus $ 360 has often been strongly felt. J, which reflects Iverson's own further work on APL, introduces tacit programming. The system Mathematica, too, is strongly influenced by APL [a5]. The "phenomenon" APL has always been controversial. At any rate, its influence on computer science, and especially on the development of programming languages, has been considerable [a3].

#### References

[a1] | G.F. (ed.) Hoffnagle, "13 papers on the occasion of the 25th anniversary of APL" IBM Systems J. , 30 : 4 (1991) |

[a2] | K.E. Iverson, "A programming language" , Wiley (1962) |

[a3] | K.E. Iverson, "Notation as a tool of thought, 1979 Turing Award Lecture" Comm. ACM 23 (1980) pp. 444–465 |

[a4] | P. Wegner, "Programming languages — the first 25 years" IEEE Trans. Comp. , C–25 (1976) pp. 1207–1225 |

[a5] | S. Wolfram, "Mathematica: A system for doing mathematics by computer" , Addison-Wesley (1988) |

**How to Cite This Entry:**

APL.

*Encyclopedia of Mathematics.*URL: http://encyclopediaofmath.org/index.php?title=APL&oldid=45194