APL-The Language Debugging Capabilities, Entirely in APL Terms (No Core Symbol Denotes an APL Function Named' 'Compress," Dumps Or Other Machine-Related Details)
Total Page:16
File Type:pdf, Size:1020Kb
DANIEL BROCKLEBANK APL - THE LANGUAGE Computer programming languages, once the specialized tools of a few technically trained peo p.le, are now fundamental to the education and activities of millions of people in many profes SIons, trades, and arts. The most widely known programming languages (Basic, Fortran, Pascal, etc.) have a strong commonality of concepts and symbols; as a collection, they determine our soci ety's general understanding of what programming languages are like. There are, however, several ~anguages of g~eat interest and quality that are strikingly different. One such language, which shares ItS acronym WIth the Applied Physics Laboratory, is APL (A Programming Language). A SHORT HISTORY OF APL it struggled through the 1970s. Its international con Over 20 years ago, Kenneth E. Iverson published tingent of enthusiasts was continuously hampered by a text with the rather unprepossessing title, A inefficient machine use, poor availability of suitable terminal hardware, and, as always, strong resistance Programming Language. I Dr. Iverson was of the opinion that neither conventional mathematical nota to a highly unconventional language. tions nor the emerging Fortran-like programming lan At the Applied Physics Laboratory, the APL lan guages were conducive to the fluent expression, guage and its practical use have been ongoing concerns publication, and discussion of algorithms-the many of the F. T. McClure Computing Center, whose staff alternative ideas and techniques for carrying out com has long been convinced of its value. Addressing the putation. His text presented a solution to this nota inefficiency problems, the Computing Center devel tion dilemma: a new formal language for writing clear, oped special APL systems software for the IBM concise computer programs. To demonstrate the val 360/91 computer. That software provided a dramatic ue of such a language, he used it to present a variety imp.rovement in the speed of APL language programs, of interesting, nontrivial algorithms (such as those for achIeved largely by the thorough use of the high-speed sorting lists of numbers or for "parsing" and analyz "vector" processing capabilities of the machine. APL ing statements written in other programming lan at APL was the fastest known implementation of the guages). language anywhere in the free world. The APL language, which is used extensively When the Computing Center was upgraded to the IBM 3033 processors, the speed of the 360/91 was par throughout the world today, 2 looks only remotely like the notation presented in Iverson's seminal text, tially sacrificed, but a new opportunity arose: to build although it does retain many of the fundamental con an APL system to handle very large applications (us cepts. The original notation could not be entered into ing virtual memory technology and bulk data handling techniques). Since its introduction in 1978 this a computer to be acted upon; it was confined to black 4 ' boards, pencil and paper, and the published literature. system has been used regularly by hundreds of Lab- Only through manual translation into Fortran or some oratory staff members for many purposes. other language could Iverson's notation actually Now, in 1984, APL is available for nearly every "come to life" in the real world of computing. computer in the marketplace. It is also a featured ser Through collaboration with others, most notably vice of numerous commercial time-sharing companies including one that specializes in up-to-date (hourly) Adin Falkoff, Dr. Iverson designed another APL 3 in~ that could be used in a practical way on time-shared ternational financial databases. Most significantly, interactive computer systems. By 1970, the APL lan APL is now available for personal computers,5 thus guage service was in use by thousands of people, in bringing it within reach of everyone. The inexorable cluding the research and design staff of IBM (whose trend toward more powerful, less expensive computers various System 360 computers hosted the APL ser is bringing APL out into the world it was designed for: vices), the staff of the NASA Goddard Space Flight the world of learning, intellectual satisfaction, human Center, and the financial planners of a number of ma productivity, timely right answers, and smooth integra jor corporations. The elegant yet practical APL won tion of computing and education. the praise of many of its users, just as it evoked stern criticism from the established data processing and aca A BRIEF LOOK AT THE APL LANGUAGE demic computing communities. APL is international in character. It uses symbols APL received only a modicum of software engineer instead of words borrowed from natural language (al ing support from the principal computer vendors as though some of the symbols are indeed derived from 280 Johns Hopkins APL Technical Digest the Greek alphabet). In this sense, APL is compara ble to traditional notations of mathematics. The sym bols require a special keyboard (Fig. 1) and display device for interacting with the computer. (Today, numerous manufacturers offer APL-equipped termi nals and personal computers.) Much of APL is familiar and reminds us of our fun damentallearnings in arithmetic and algebra. In fact, APL can be used very effectively as a "laboratory" Figure 1-Typical APL keyboard. for learning algebra. 6 When being taught French, American students often spend hours speaking the lan guage in a laboratory. When learning mathematics, APL functions are defined upon rectangular arrays however, there is usually no such laboratory in which of data, not just upon individual scalar values. A rec to experience and experiment with the concepts. When tangular array contains data arranged along zero or computers are introduced, ostensibly for that purpose, more axes or dimensions, not necessarily all having the the languages used (almost always Basic) have but a same length. A simple list of values is a rectangular weak relationship to the substance of the material be array with only one dimension (a vector); a square ma ing taught. APL offers an attractive, substantive al trix is a rectangular array with two equal dimensions. ternative. A typical financial report often contains tables of num Consider the familiarity of the following APL bers that can easily be recognized as rectangular ar symbols: rays. This characteristic results in what may be the + Addition single most important contribution of the language, Subtraction particularly in light of evolving supercomputer tech x Multiplication niques: those who "think in APL" 7 naturally think Division in terms of vector and array processing. Factorial APL achieves generality through the simplicity and uniformity of its rules (as contrasted with achieving < ::; = ~ >:;t. Comparisons Logical negation generality through exhaustive enumeration of features, /\ Logical AND (intersection) which is typical of computer paraphernalia). As a V Logical OR (union) strong source of generality, APL uses the concept of an operator, permitting one to build functions that are E Set membership I Absolute value variants of other functions. The I operator, for ex ample, can be used to create a summation function The Fortran-like languages use unfamiliar symbols out of the ordinary addition function. The resultant (such as * for multiply, I for divide, and .LT. for less summation function looks like + I and is read as "plus than). Instead of restricting his notation to the sym over. " We consider this to be highly general because bols available on the keypunch machines of the 1960s, it is simple and has many latent possibilities for which Iverson chose symbols that were and are used to teach traditional mathematics (and Fortran) has inconsistent arithmetic and that appear today on nearly every hand ad hoc notations. Consider these variations: held calculator. APL is rooted in the mathematical concept of func + 1 "plus over" Summation tion, and most of its capabilities are implemented as xl "times over" Product functions. The language is rich in interesting identi rl "max over" Maximum value ties involving many combinations of its intrinsic func LI "min over" Minimum value tions, and it is conducive to formal symbolic manip /\ 1 "and over" True for all ulation and proofs. v i "or over" True for any The familiar symbols in the previous list all imply the performance of the corresponding familiar func When applied to arrays, these reduction functions may tions. Other functions, familiar and otherwise, are be applied along any axis (i.e., down the columns or denoted by well-chosen, easily learned symbols. The across the rows). following are some examples: APL promotes human productivity by thoughtful ly automating most irrelevant aspects of the com r L Maximum and minimum puter's inner workings and by nearly eliminating the * Power need for declarative statements (DIMENSION, ® Logarithm DECLARE, etc.). Unless facing extreme limits, APL El Matrix inverse, matrix division users do not need to consider how numbers are o Circular, Pythagorean, trigono- represented internally (as binary, decimal, hexadeci metric mal, Boolean, byte, word, floating-point, etc.), nor ~ t Ascending and descending "sort" do they need to announce in advance the sizes, shapes, ~ Transpose about the diagonal or types of arrays. Furthermore, most APL implemen <P Reverse tations provide for convenient interactive testing and Volume 5, Number 3, 1984 281 D. Brocklebank - APL-The Language debugging capabilities, entirely in APL terms (no core symbol denotes an APL function named' 'compress," dumps or other machine-related details). which uses a list of 1's and O's (a Boolean vector) as its left argument to indicate which elements of its right APL AND EXPRESSIVE DIRECTNESS argument are to be kept (1) or deleted (0). For a broad class of problems, APL provides a very Now let us test function A, first by itself and then high dgreee of expressive directness. By this we mean in combination with function P: that the language is conducive to the fluent, rapid, and A 'A MAN, A PLAN, A CANAL, clear expression of many algorithms, ideas, and defi PANAMA.' nitions.