Programming Style in APL
by Kenneth E. Iverson, IBM Thomas J. Watson Research Center, Yorktown Heights, New York.
When all the techniques of program management and programming practice have been applied, there remain vast differences in quality of code produced by different programmers. These differences turn not so much upon the use of specific tricks or techniques as upon a general manner of expression, which, by analogy with natural language, we will refer to as style. This paper addresses the question of developing good programming style in APL.
Because it does not rest upon specific techniques, good style cannot be taught in a direct manner, but it can be fostered by the acquisition of certain habits of thought. The following sections should therefore be read more as examples of general habits to be identified and fostered, than as specific prescriptions of good technique.
In programming, as in the use of natural languages, questions of style depend upon the purpose of the writing. In the present paper, emphasis is placed upon clarity of expression rather than upon efficiency in space and time in execution. However, clarity is often a major contributor to efficiency, either directly, in providing a fuller understanding of the problem and leading to the choice of a better, more flexible, and more easily documented solution, or indirectly, by providing a clear and complete model which may then by adapted (perhaps by programmers other than the original designer) to the characteristics of any particular implementation of APL.
All examples are expressed in 0-origin. Examples chosen from fields unfamiliar to any reader should perhaps be skimmed lightly on first reading.
Contents
Assimilation of Primitives and Phrases
Function Definition
Generality
Identities
Proofs
Recursive Definition
Properties of Defined Functions
Efficiency
Reading
Conclusions
Appendix A. Translation from Direct to Del Form
References
See also
First published in Proceedings of An APL Users Meeting, Toronto, I.P. Sharp Associates Limited, 1978-09-19 to 20. Republished in A Source Book in APL, APL Press, 1981-09.