home *** CD-ROM | disk | FTP | other *** search
- A View of APL
-
- Blay Tarnoff
- Connecticut IBM PC Users Group
-
- To many of us who are familiar with
- BASIC, Pascal or PL/1, APL may be
- considered a very high-level
- language.
-
- APL's main advantage is its ability
- to more directly translate tasks the
- one wishes the computer to perform
- into a set of instructions the
- computer can understand. The
- expression of APL is close to the
- conceptual basis of most
- applications.
-
- The greatest sacrifice made when
- programming in APL is loss of the
- natural ability to precisely
- manipulate the internal workings of
- the computer. This manipulative
- ability may be emulated in APL, but
- usually only at the expense of speed.
-
- The trade off between
- speed/efficiency and ease of
- programming is similar to that
- encountered when deciding to program
- in, for example, BASIC as opposed to
- Assembly Language.
-
- The great strength of APL is its
- combination of power and simplicity.
- APL's power stems mostly from its
- treatment of arrays as entire
- objects, rather than as
- agglomorations of single cells. Its
- simplicity derives from its (largely)
- concise and well-founded axiomatic
- design.
-
- Power:
- One does best to think of an array,
- and perform operations on that array
- as an entity. APL provides the tools
- to accomplish this. For example, if A
- and B are arrays of length 3, then
- the result of the operation:
-
- A,B
-
- will be another array of length 6
- which is the concatenation of arrays
- A and B. The result of the
- operation:
-
- A+B
-
- will be another array of length 3,
- where each element will be the sum of
- the corresponding elements of A and B
- (i.e. result(I) = A(I) + B(I) ). The
- result of the operation:
-
- φA
-
- will be A backwards. The result of
- the operation:
-
- 1 0 1 /A
-
- will be the same as the result of:
-
- A[1 3]
-
- The result is to select the first and
- third elements of A, producing a new
- array of length 2. These operations
- can be generalized to 2-,3-,4- and
- higher-dimensional arrays. The
- results of these operations may then
- be assigned to new variable names,
- passed on for further calculation or
- manipulation, or printed. In this
- manner, arrays of any dimension are
- manipulated, dissected, reshaped, and
- pasted together, forming new objects.
- Iterative loops are rarely needed to
- generate results or to initialize
- arrays of any dimension.
-
- Simplicity:
- For the most part, all "things" in
- APL fall into three categories. They
- are either variables(arrays),
- functions (+, -, φ, etc.), or
- operators. Operators take functions
- as arguments (parameters) and produce
- new functions as results. Functions
- take arrays as arguments and produce
- arrays as results (or produce no
- results).
-
- The user is provided with the means
- to define his or her own functions.
- These user-defined functions are APL
- "programs". Once user-defined, these
- functions may be used inside other
- functions (programs) exactly as the
- primitives (+ ,- ,φ etc.) are used.
-
- There is no special input parameter
- syntax for each function. All
- functions, be they user-defined or
- primitive, accept either both a left
- and right argument (like + in the
- example), a right argument only
- (like φ in the example), or no
- arguments at all.
-
- There is no hierarchy among
- functions. All operations proceed
- from right to left. The expression
- 2-3x4-5 is evaluated identically to
- the expression 2-(3x(4-5)), not
- (2-(3x4))-5. Besides simplicity, this
- lends improved readability to the
- language.
-
- It is commonly believed that since
- APL's forte is array manipulation it
- is only useful as an engineering
- tool. This is not the case. APL is
- useful for nearly all applications,
- with few drawbacks.
-
- Volumes can be (and have been)
- written on all facets of the subject
- of APL. APL requires no knowledge of
- computers because such
- computer-oriented things as space
- allocation, variable declaration,
- variable type definition, etc. are
- handled automatically and are
- transparent to the user. An
- understanding of high-school linear
- algebra is helpful, but hardly
- essential. APL was originally used to
- teach linear algebra to slower
- students before it was implemented on
- computer.
-
- I cannot help but feel that for
- people who have never programmed, APL
- is an excellent place to start. For
- those people who already program in
- other languages, learning APL will
- greatly reduce their turnaround time.