home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / TNH_PC.ZIP / TARNOFF.NL < prev    next >
Encoding:
Text File  |  1987-01-14  |  4.4 KB  |  162 lines

  1. A View of APL
  2.  
  3.              Blay Tarnoff
  4.     Connecticut IBM PC Users Group
  5.  
  6. To many of us who are familiar with
  7. BASIC, Pascal or PL/1, APL may be
  8. considered a very high-level
  9. language.
  10.  
  11. APL's main advantage is its ability
  12. to more directly translate tasks the
  13. one wishes the computer to perform
  14. into a set of instructions the
  15. computer can understand. The
  16. expression of APL is close to the
  17. conceptual basis of most
  18. applications.
  19.  
  20. The greatest sacrifice made when
  21. programming in APL is loss of the
  22. natural ability to precisely
  23. manipulate the internal workings of
  24. the computer.  This manipulative
  25. ability may be emulated in APL, but
  26. usually only at the expense of speed.
  27.  
  28. The trade off between
  29. speed/efficiency and ease of
  30. programming is similar to that
  31. encountered when deciding to program
  32. in, for example, BASIC as opposed to
  33. Assembly Language.
  34.  
  35. The great strength of APL is its
  36. combination of power  and simplicity.
  37. APL's power stems mostly from its
  38. treatment of arrays as entire
  39. objects, rather than as
  40. agglomorations of single cells. Its
  41. simplicity derives from its (largely)
  42. concise and well-founded axiomatic
  43. design.
  44.  
  45. Power:
  46. One does best to think of an array,
  47. and perform operations on that array
  48. as an entity. APL provides the tools
  49. to accomplish this. For example, if A
  50. and B are arrays of length 3, then
  51. the result of the operation:
  52.  
  53.      A,B
  54.  
  55. will be another array of length 6
  56. which is the concatenation of arrays
  57. A and B.  The result of the
  58. operation:
  59.  
  60.      A+B
  61.  
  62. will be another array of length 3,
  63. where each element will be the sum of
  64. the corresponding elements of A and B
  65. (i.e. result(I) = A(I) + B(I) ). The
  66. result of the operation:
  67.  
  68.      φA
  69.  
  70. will be A backwards. The result of
  71. the operation:
  72.  
  73.      1 0 1 /A
  74.  
  75. will be the same as the result of:
  76.  
  77.      A[1 3]
  78.  
  79. The result is to select the first and
  80. third elements of A, producing a new
  81. array of length 2.  These operations
  82. can be generalized to 2-,3-,4- and
  83. higher-dimensional arrays.  The
  84. results of these operations may then
  85. be assigned to new variable names,
  86. passed on for further calculation or
  87. manipulation, or printed.  In this
  88. manner, arrays of any dimension are
  89. manipulated, dissected, reshaped, and
  90. pasted together, forming new objects.
  91. Iterative loops are rarely needed to
  92. generate results or to initialize
  93. arrays of any dimension.
  94.  
  95. Simplicity:
  96. For the most part, all "things" in
  97. APL fall into three categories.  They
  98. are either variables(arrays),
  99. functions (+, -, φ, etc.), or
  100. operators.  Operators take functions
  101. as arguments (parameters) and produce
  102. new functions as results. Functions
  103. take arrays as arguments and produce
  104. arrays as results (or produce no
  105. results).
  106.  
  107. The user is provided with the means
  108. to define his or her own functions.
  109. These user-defined functions are APL
  110. "programs". Once user-defined, these
  111. functions may be used inside other
  112. functions (programs) exactly as the
  113. primitives (+ ,- ,φ etc.) are used.
  114.  
  115. There is no special input parameter
  116. syntax for each function. All
  117. functions, be they user-defined or
  118. primitive, accept either both a left
  119. and right argument (like + in the
  120. example), a right  argument only
  121. (like φ in the example), or no
  122. arguments at all.
  123.  
  124. There is no hierarchy among
  125. functions. All operations proceed
  126. from right to left. The expression
  127. 2-3x4-5 is evaluated identically to
  128. the expression 2-(3x(4-5)), not
  129. (2-(3x4))-5. Besides simplicity, this
  130. lends improved readability to the
  131. language.
  132.  
  133. It is commonly believed that since
  134. APL's forte is array manipulation it
  135. is only useful as an engineering
  136. tool. This is not the case. APL is
  137. useful for nearly all applications,
  138. with few drawbacks.
  139.  
  140. Volumes can be (and have been)
  141. written on all facets of the subject
  142. of APL. APL requires no knowledge of
  143. computers because such
  144. computer-oriented things as space
  145. allocation, variable declaration,
  146. variable type definition, etc. are
  147. handled automatically and are
  148. transparent to the user. An
  149. understanding of high-school linear
  150. algebra is helpful, but hardly
  151. essential. APL was originally used to
  152. teach linear algebra to slower
  153. students before it was implemented on
  154. computer.
  155.  
  156. I cannot help but feel that for
  157. people who have never programmed, APL
  158. is an excellent place to start. For
  159. those people who already program in
  160. other languages, learning APL will
  161. greatly reduce their turnaround time.
  162.