APL (A Programming Language)

Nick Schrader
ELP-2018
Published in
3 min readMay 22, 2018

APL (A Programming Language) was first a mathematical notation developed by Kenneth E. Iverson in 1962. It was part of the book “A Programming Language” that he published when working at IBM. Designed for expressing algorithms very concisely, the “Iverson notation” used special symbols for operators and functions that were applied to multidimensional arrays.

Kenneth E. Iverson (CC BY 4.0, https://en.wikipedia.org/w/index.php?curid=55607169)

The first implementation, “Personalized Array Translator” (PAT), was written in 1963 by Herbert Hellerman working at IBM. Two years later Iverson wrote his own implementation, called “Iverson System” (IVSYS). In the absence of CRT terminals, most computers used paper printing terminals, so being limited by the typewriter, both implementations used English keywords instead of any special symbols. After having developed a special type element for its terminals, IBM released “APL\360”, the first implementation capable of everything Iverson described in his book. It was maintained until 1983. In 1968 IBM released “APL\1130”, the first publicly available implementation. First desktop computers featuring APL with a CRT screen and a suitable keyboard were available as of the mid-70s, whereas most desktop computers were equipped with BASIC interpreters. Even Bill Gates claimed in 1976 that Microsoft would develop an APL interpreter, but it was never released.

ALP keyboard layout for IBM 5100, first available in 1975 with APL\360 (CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=2456412)

APL2 was released by IBM in 1984 and a significant re-implementation of APL. In 2018 it is still available, notably for Linux and Windows. Another very known implementation is Dyalog APL by the British company Dyalog Ltd. It is based on APL2 and got extensions for object-oriented and functional programming. Dyalog APL was first released in 1983 and, in 2018, is still available, notably for Linux, MacOS and Windows.

There is a clear distinction between functions and operators. Functions take arrays as arguments and return arrays as results. Operators take functions as arguments and return derived functions. For example, similar to well known functional programming languages, the “sum” function can be obtained by applying the “reduce” operator to the “add” function. Moreover, all functions and operators are primitives. Any APL program is made out of monadic or dyadic primitives (i.e. having one or two arguments) acting on arrays. In the case of a monadic function, the only argument is on the right. In case of a monadic operator, the only argument is to the left. In case of any dyadic primitive, there is one argument to its left and one to its right. However, there are no parentheses to express what exactly the arguments are (unlike in C where all arguments are within parentheses) and all primitives have the same precedence. Thus ALP code is understood from right to left.

Example: The expression “x[⍋x←6?40]” generates a set known as “Pick 6 Lottery” in the US. The function “6?40” selects 6 random integers from 1 to 40, guaranteed non-repeating. “x←” is an operator assigning the result to the variable x, and the function “⍋x” returns the indices that would put x into ascending order. Finally “x[]” is an operator indexing x so that the set of random integers is sorted.

As APL manipulates mainly arrays, it lends itself well to parallelism. Furthermore, matrix operations are very efficient. Some people (notably Neville Holmes of IBM Australia) argue that APL is rather a calculation tool than a programming language as it can be used by people with high mathematical skills put no programming experience. In addition to education, it is mainly used for commercial and scientific purposes, such as in finance, in the insurance industry and for artificial intelligence.

Most implementations were interpreters, but some tried to compile APL to machine code to achieve performance gains. However, they were rather an exception. Most modern compilers translate APL to C code, thus being platform independent.

In 1979 Iverson received the Turing award for this work. The MATLAB language appeared first in the late 70s and was strongly influenced by APL.

https://en.wikipedia.org/wiki/APL_(programming_language)

--

--