What is APL?
APL is a programming language for extremely fast program development. Period!
Thanks to its power, programs are written much faster in APL than
in most other languages.
Opinions differ how fast development in APL is compared to development in other languages. My own feeling is that I develop roughly 5 to 10 times as much in a week when I use APL than when I used PL/I. Some APL-programmers claim a speed ratio of 1:10; using APL they can finish a project in one or two months against a year with some conventional language. Datamation (DA92) cites a more conservative figure of 1 to 4 times as much when comparing APL to C. But even then, an APL programmer only needs a day to complete a problem that might take a C programmer nearly one week.
For this reason APL is especially suitable for prototyping.
Why so fast?If development in APL is so fast, what is the secret? Several characteristics of APL contribute to this speed of development:
- APL is an interpreter. At any moment and at any program line one can interrupt execution, query local and global variables, try out alternative modules or expressions, correct erroneous program lines and continue execution at any suitable place.
- APL has powerful functions. APL has many powerful functions that you may not need for every application but that come in handy when you need them (for example matrix inverse, many trigonometric functions and their inverses, sorting, searching and many others).
- APL is problem oriented, not machine oriented. APL screens you from machine quirks. For example, there are no type-declarations, APL takes care of truncation errors in comparing results of expressions and many expressions don't need element by element specification (explicit loops).
- APL is concise. APL uses (suggestive) symbols for its operations. So APL programs only need a very small amount of keystrokes. This not only accounts for quicker typing, but more importantly for very concise programs. This makes APL programs very comprehensible. One can see and understand rather complex operations in a glance. Experienced APL programmers learn to recognize idioms, small sets of functions that perform complex operations but are recognized as one "gestalt".
- APL program development is fast. This seems a funny circular argument, but there is some logic in it. Because of it's speed and terseness, one APL programmer can do a job that needs a team when using a conventional language. A team always wastes time in communication and in repairing problems due to misunderstandings. This is missing in one-person APL projects.
VAR sum,ARRAY data[1..500] OF REAL i INTEGER; BEGIN WRITE('Number of data=..'); READLN(n); sum:=0; FOR i:=1 TO n DO BEGIN READ(data[i]); sum:=sum+data[i] END; WRITELN(sum); END.but in APL you simply program the sum of inputs (no need for loops) as: ,
and the mean is also very tersely formulated as: .
History of APL
At the end of this what-paragraph we will tell in a nutshell about the birth of APL.
APL is an acronym for "A Programming Language". The language was designed by Kenneth Iverson in the sixties. His purpose was to develop an improved mathematical notation, as he considered conventional math notation not very consistent. Iverson was joined by Adin Falkoff, Larry Breed and Philip Abrahams. They set out to implement this notation as a programming language. In 1966 APL emerged as a computer programming language. This makes APL a rather old language along with old hands like ALGOL (1958), Basic (1965), COBOL (1960), Fortran (1953) and PL/I (1965). Notwithstanding its age, many ideas in APL are still unique, while others have found their way into modern languages.
Since 1966 APL has been implemented on many computers, mainly large mainframes like those of Burroughs, IBM and Siemens. Initially APL missed the proliferation of microcomputers because APL needed more power (storage as well as speed) than was available in those early years. Very few of those early microcomputers had APL; exceptions were Tandy's TRs90 and Commodore's PET. It was the rise of the more powerful 16-bits micro computers that enabled APL to settle commercially on microcomputers. Nowadays one finds APL on nearly all computers, whether micro, mini or mainframe.
In the eighties APL had a major extension: nested arrays. Up to then arrays always had scalar elements (numbers or characters). In the N.A. version (Nested Array version) each array-element can be an array itself (which in turn ....).
This N.A. extension does not infringe on the standard APL syntax.
For example "5+AR" still adds five to all elements of AR,
whether AR is a "flat" array of say size 5x10x20x30 elements or a
nested array of say 3 elements with element 1 scalar, element 2 an
array of 1000 elements and element 3 a 5x10x20x30 array.
Furthermore only a few function extensions were required to handle the increased power.
Research showed that APL's power increased substantially in the NA extension. Its already high Halstead score which was 3.07 for flat APL increased to 3.66 for N.A. APL as compared to 1.14 for Fortran and 1.53 for PL/I (see F.H.D. van Batenburg, E.deRidder, J.de Kerf (1998): APL extended compared with other languages according to Halstead's theory ACM Sigplan 1998, 33(6)54-60 ) .
APL is a programming language that enables extremely fast program development.
I would venture to state that this is the one and the best reason to use APL. Quick development is appreciated whether one is working commercially (where development time is money) or in science (quick programming leaves more time for science).
A second reason to program in APL is that one experienced APL programmer can handle rather complex problems on his own. No need to have a team where a lot of planning and communication is necessary and misunderstanding is inevitable.
Finally I have to confess there is a "soft" reason too. Personally it gives me a lot of satisfaction to develop a complex program in a short time, especially if it looks elegant. This is why I use APL. But this is not something that everybody should necessarily share.
Where is APL used?
APL is used over a wide spectrum of applications, varying from prototyping, administration, to science in a great diversity of applications, varying from data mining to mathematical applications such as actuarial use.
Where to find APL and APL info?
If the above information has made you interested to learn more about APL you can...
- consult the FAQ that is kept by Sam Sirlin for APL programmers Sam Sirlin APL FAQ or consult my "APL-novices"-FAQ (FAQ).
- download public domain APL (see section Public Domain APL).
- buy APL; contact APL vendors (see section Websites for APL).
- visit APL conferences (see section APL conferences & publications).
- subscribe to the APL newsgroup, mailinglist or to APL user groups (see section Websites for APL).
- subscribe to APL journals (see section APL conferences & publications).
- buy/read APL books (see section APL conferences & publications).
This section deals with questions that are frequently asked about APL.
It is useful to make a distinction between 2 types of questions.
Some questions are frequently asked by APL programmers, others by non-APL-ers or APL novices. For the first category (APL programmers), Sam Sirlin compiled questions with answers in an APL-FAQ. This is available at...
- Where can I find APL for machine X?
- How do I use APL on an XX terminal connected to machine YY? What about APL keyboards/stickers?
- Can I compile APL?
- What tools exist for APL?
- Can I get an APL font for X?
- What information exists online about APL?
- How do I get book Y?
- What good APL books exist?
- What user groups exist?
- What's the latest APL conference?
- How do I pass APL functions from one APL to another?
- How do I write APL using only ASCII?
- Where can I find APL employment information?
Novices have quite different questions. Those that were asked to me most frequently....
- Is APL code easy to read?
- Is APL fast?
- Is APL only for mathematics?
- Is APL easy to learn?
- Is APL expensive?
1. Is APL code easy to read?Yes and no.
First of all, yes, undeniably there is APL code around that is hard to read. Just as there is Basic code or Pascal code that is very hard to read.
However a careful designed and written APL program is no harder to read than one in Basic or Pascal.
The point is that one should compare programs rather than program lines. The misconception that APL is hard to read stems from the fact that people tend to compare program-lines. APL lines require much more time to read than lines in any conventional programming language. Because APL is so terse, one line of code can perform a complex task that may need several pages of Pascal. Subsequently, a naive reader is extremely disappointed that such a line in APL requires far more time to read than one line in Pascal. In general however, that one line of APL does not require longer to study than the several pages that Pascal needs for that same task.
An observation that also suggests unreadability is that APL programmers tend to give up reading an APL program quickly and start programming it themselves. This is not due to unreadability of the APL-code, but rather to the fact that one can program so quickly in APL.
So the answer is: In general APL code is more readable than code of a similar function written in a conventional language.
2. Is APL fast?Again, yes and no.
APL is distributed as an interpreter. And interpreters are by definition slower than compiled execution modules.
On the other hand, APL programs are littered with
With this I mean constructs where you don't need to specify much code
in APL (it performs that implicitly) but are required to code much explicitly
in conventional languages.
For example in APL one does not have to program loops explicitly when
adding or multiplying multi-dimensional arrays
("+/array" and "x/array" is fine) and one does not have to
program IF/ELSE statements explicitly when selecting data
(using "replicate" to select as in "(data>12)/data").
Those constructs are fast because they do not have significant overhead for interpretation. Moreover, many array operations have been extremely optimized in the more than 30 years existence of APL.
So the answer is: In principle APL execution is slower than compiled code; in practice the difference is often negligible (and often irrelevant).
3. Is APL only for mathematics?This is not true at all. It is true that APL is very powerful in its mathematical capabilities. So many actuaries use APL.
However APL is also very popular for prototyping, for "spidering" (being the central spider in the web that activates other COBOL, Fortran, SQL programs to produce data that are processed and pushed to another program) and for driving database systems.
So APL is used over a wide spectrum of applications, varying from prototyping, administration, science and commercial use from record keeping to mathematical applications such as actuarial use.
In order to illustrate this point, look at some projects that were published in conference papers and in Quote Quad journal.
So the answer is: APL is strong in mathematical fields as well as in other application fields.
4. Is APL easy to learn?Yes and no; it is true that APL is not the most simple language to learn.
It is not so hard to become a reasonable expert in Basic or Pascal. To become an expert in APL takes much longer. And to enjoy the fruits of developing so much quicker in APL than in Basic or in Pascal requires a minimal level of expertise.
However, this observation needs some clarification. To obtain the level of expertise in APL that is comparable to an "expert Pascal Programmer" does not require much more than it takes for the Pascal student; a bit more, but not much. However to harness more of the typical APL power that gives you the real advantage is harder. This is roughly shown in the graph where you see that APL is a bit harder to learn, but also that you can acquire much more power in the end.
So the answer is: APL is probably slightly harder to learn, but one can acquire much more power than one ever can do in a conventional language.
5. Is APL expensive?Yes, unfortunately current APL systems are fairly expensive; about US$1500 or more (see vendors).
Nevertheless, there are free APL systems. See "Public domain APL".
APL ISO standards
Similar to your film rolls that have a standardized "ISO"-speed, there
is an ISO standard for the programming language APL too.
ISO (=International Standard Organisation www.iso.ch) betrothed IEC (=International Electrotechnical Commission). In 1987 they begot JTC1 (=Joint Technical Committee) for standardization of all things human, ranging from film speed, paper sizes to procedures.
The JTC1 formed a Standard Committee for program languages: SC22 (www.open-std.org/jtc1/sc22/); in SC22 several languages are represented by their own working group. WG3 is the Working Group in SC22 for APL standardization. This working group is chaired by Prof.L.J.Dickey (email: email@example.com).
Up to now the fruits of WG3 are :
- Classical (or "flat" APL) was standardized in 1989 and specified in the publication IS-08484.
- The standard with the nested array extension (N.A. APL) was finished in 2000.
It is available at ISO and downloadable from www.math.uwaterloo.ca/~ljdickey/apl-rep/docs/is13751.pdf.
APL programming standards
APL programmers can write fairly unreadable programs. This is not unique for APL programmers, but APL programmers are not better than any other programmer.
Writing very clear programs is an art. This art can be mastered by years and years of making bad mistakes. Another option is to learn from others who made many of such mistakes in the past.
The Dutch APL User Group decided to write down a number of suggestions that could help preventing such mistakes. This developed into the "ASWI programming standards for APL programs" written by F.H.D. van Batenburg, T.R.C.Bonnema, L.van Geldrop, H.van Loon and B.Smoor. It can be downloaded as an PDF document at "ASWI programming standards for APL programs". If you have any trouble in getting this document, please contact me by email and I will send this file as an attachment.
APL language proposals
APL is a very powerful language.
Nevertheless, there is room for improvement.
Old APL versions only had the GOTO for flow-control and no control structure. Modern APL versions have added the "usual" concepts: IF...ELSE, WHILE...END, DO...UNTIL and SELECT...CASE...ENDSELECT.
Unfortunately many vendors implemented these concepts using the verbose constructs from the conventional languages. Although APL needs better structural constructs than the mere GOTO, my position is that APL should not gratuitously copy the syntax from conventional languages but seek a more APL-lish implementation.
My favorite APL-lish implementation of structured control is one single function (baptised control) that uses the -symbol that is used for blocks since the early beginning of APL. This extension implements all necessary control structures in one: condition, alternatives, fixed repetition as well as while repetition.
Syntax of this proposed control is:
controlling_expression <-- begin of control block ... <--- executable_expressions <-- end of control blockThe executable_expressions are done as many times as the value of the controlling_expression dictates. This results into fixed iteration if the controlling expression yields an integer and into conditional execute if the result is either 1 or 0.
If the controlling expression yields a negative integer -m, it behaves like a while construction. At first the effect is similar as if the integer was positive (the executable_expression is done m times), but at the end the negative value forces APL to execute the controlling expression again. If that results in a 0, 1 or another integer n, the executable_expression is done 0, 1 or n times only; but if that result was a negative value again, another while-step is done.
Some examples can illustrate the use:
- Fixed repetition.
Execute 365 times:
Execute only for A equal to 0:
- While repetition.
While is implemented similar to fixed iteration, but with a negative iteration counter to indicate that at the end of the iterations, APL should check the condition again.
Execute as long as A equals 0:
For alternatives the controlling expression should have as many numbers as there are alternatives, and each executable alternative is headed by a label-less colon ":".
:'XXX is a variable'
:'XXX is a function'
These examples show how control is used monadically to define
the beginning of a control block and niladically to define the end of that block.
This symbol control can also be applied dyadically for single line control. In that case the syntax is:
Some examples that illustrate this dyadic use for single lines:
Assign 3 to variable LARG if LARG doesn't exist:
- Fixed repetition.
Read 365 samples:
- Fixed repetition.
Factorial computation (rather artificial):
- While repetition.
Continue to collect user input, until finally the user enters empty line:
Division only if B is not zero:
If/else: assign color RED to variable FLOW if ANSWR is 1, otherwise assign YELLOW.
If/else: Report zero division if B=0, otherwise perform division:
Seven alternatives: do either of 7 modules depending on the value of variable DAY:
This type of structured control is implemented for blocks in APL2C (http://www.apl2c.de/).
J is a language with most of the ideas and power from APL. In many ways it is even superior to APL. As K. Iverson, the designer of APL and J, once remarked, in J he tried to keep the good things of APL and correct the mistakes that he made in APL.
Moreover, J is further developed and distributed by a bunch of very enthusiastic people. This accounts for the fact that many new ideas and improvements still find their way into J, notwithstanding the fact that it was already very powerful to begin with.
Personally I concur with Iverson that J is an improvement to APL
in many ways, except for one powerful feature of APL: the special
characters that are used in APL.
Iverson considered these special characters of APL a mistake and
consequently J uses the normal ASCII characters.
However, these special characters let me read APL lines far easier
than J lines.
Another weak point of J is the written documentation. This written documentation has not kept up with the rapid speed that new developments in J features took place.
Both these points are criticism that are not shared by everybody, though.
Contrary to most APL implementations, J is very reasonable priced.
And for personal use it is free.
Furthermore, there are several tutorials to learn more about specific features of J.
All this can be found at the J site.
A selection of useful websites for J are...
- THE site for the newest version of J and a lot of other information is the official J site http://www.jsoftware.com.
- some older free versions of J at Waterloo: http://www.math.uwaterloo.ca/apl_archives/j/.
- and: http://www.jsoftware.com/archive.htm.
Free Public domain APL
- If you use Linux, you are blessed. MicroAPL makes available their excellent APL (with nested arrays) for free for the unix platform. You can download it at www.microapl.co.uk/apl/aplx_downloads.html.
- Another good offer is provided by I.P.Sharp. This version has boxed nested arrays. It can be requested by emailing to I.P.Sharp (firstname.lastname@example.org); see their website at http://www.soliton.com/solutions-linux.html.
- Recently a full APL on experimental base for Windows is NARS (Nested Arrays Research System). This also has full APL nested array capabilities, but it has no GUI-features nor has it file-system capabilities. See the website www.nars2000.org/.
- Another APL for Windows is APL2C, at http://www.apl2c.de/. This APL has nested arrays, it is fully ISO extended compatible and it has implemented the APL-lish control structures as described previously in APL language proposals. Furthermore it has the option to create C-source code from an APL workspace. Unfortunately, like the previous APL, it has no GUI-capabilities.
- For "classical" APL without nested arrays for Windows, there is the STSC's DOS version APL*PLUS or the slightly newer APLSE available at (http://www.math.uwaterloo.ca/apl_archives/apl/apl-plus/). This is a full APL system that has all the features that APL programmers loved so much in the time that DOS was the operating system of PCs (no GUI or nested arrays here).
- Finally there is IBM's Try APL to be downloaded from (http://www-306.ibm.com/software/awdtools/apl/) or from (http://www.math.uwaterloo.ca/apl_archives/apl/tryapl2/). It is a DOS application too. Contrary to the previous APL, it has all nested array features. However (also contrary to the previous APL's) it is handicapped: it is slow, it has no file I/O, nor GUI provisions and it has a memory restriction.
Websites for APL
APL vendorsCommercial vendors of APL systems are:
- APL2000 (was Manugistics, was APL*PLUS): http://www.apl2000.com or email to email@example.com
- Dyadic systems (Dyalog APL): http://www.dyalog.com/ or email to firstname.lastname@example.org
- IBM (APL2): http://www-306.ibm.com/software/awdtools/apl/apl2-v2.html or email to email@example.com
- MicroAPL (APLX for MacOS, Windows and Unix): http://www.microapl.co.uk or email to firstname.lastname@example.org
Newsgroup and mailing lists
- APL has a newsgroup on the web that can be reached: comp.lang.apl.
- another discussiongroup is: //groups.google.com/group/comp.lang.apl
- APL has a mailing list.
You can subscribe by sending the message
"SUBSCRIBE APL-L yourname" to LISTSERV@LISTSERV.UNB.CA.
- J has a mailing list.
You can subscribe by sending the message
"SUBSCRIBE JSOFTWARE" to MAJORDOMO@LISTS.INTERLOG.COM.
APL afficionadosApart from the APL FAQ which is the best starting point to get information, other useful sites are:
- One of the best web sites for APL is Jim Weigang's (author of the study book "APL notes"):
- A rather succinct site, but with all the relevant information together
- Another very informative site is Rex Swain's; choose APLinfo at:
- Information about statistical graphics, including the
APL2STAT package developed by Friendly and Fox for APL2:
- Waterloo APL and J archives:
Active APL user groups
- ACM Special Interest Group for APL (SIGAPL):
- British APL Association:
- Finnish APL Association:
- Toronto APL SIG:
- FinnAPL Idiom toolkit:
- Toronto Toolkit:
- Waterloo archives:
APL conferences & publications
APL is one of the few programming languages that has an international conference every year.
User conference of APL2000 is in Bethesda (Maryland) from 10-11 november (see http://www.apl2000.com/2008UserConference.php for more details).
Dyalog APL user conference is in LO-Skolen in Denmark from October 12-15 (see http://www.dyalog.com/dyalog_08.htm for more details).
Dyalog had it's yearly conference in Glasgow from 14 - 16 November.
- APL2003 "Stretching the mind"
In 2003 the APL conference was held as a part of the 32nd conference on Array Programming Languages in San Diego (calif.) from June 11 - June 14.
- APL2002 was in Madrid Spain from 22-25 july.
Chairman was Manuel Alfonseca (email: Manuel.Alfonseca@uam.es).
- APL2001 was at Yale University in New Haven, Connecticut, U.S.A..
Chairman was Ed Shaw (email: email@example.com).
- APL2000 was in Berlin at the Department of Computer Science of the
Chairman was be Dieter Lattermann (email: firstname.lastname@example.org).
- APL99 was in Scranton (Penssylvania, USA).
- APL98 was in Rome.
- APL97 was in Toronto.
- APL96 was in Lancaster.
- APL95 was in San Antonio (Texas, USA).
JournalsThere used to be several journals, publishing regularly about APL. Some names are Quote Quad (ACM/SIGAPL) and Gimme Arrays! (Toronto APL SIG). Currently only one journal is available which is:
- Vector (British APL Association): http://www.vector.org.uk
BooksSome books to learn APL are:
- Brown et. al.APL2 at a Glance, Prentice Hall, ISBN 0-13-038670-7.
- Dalois,Maurice: Introduction to APL*PLUS PC, available from EducAPL, US$30, US$10 for overseas shipping.
- Gilman,Leonard & Rose,Allen.J.: APL - An Interactive Approach, Wiley, ISBN 220-471-30022-5.
- McGrew,Jon: An Introduction to APL2, IBM (SH20-9229).
- Peelle,Howard.A.: APL an Introduction, Holt, Rinehart & Winston, ISBN 0-03-004953-9.
- Thomson,Norman D. & Polivka,Raymond P.: APL2 in Depth, Springer-Verlag, 1995, ISBN 0-387-94213-0 ($39.95).
- Turner,Jerry R.: APL IS EASY!, Manugistics, 1993.
- Weigang,Jim: APL Notes, Available from J. Weigang (includes APL*PLUS interpreter) 68 Plateau Circle West Springfield, MA, 01089, USA price: US$29 postpaid in US & Canada, US$38 overseas.
- "J Primer," Iverson Software, 1996, ISBN 1-895721-14-8
- Batenburg,F.H.D.van: Mikrokursus modelbouw & simulatie voor Biologen.