Difference between revisions of "APL (programming language)"

From formulasearchengine
Jump to navigation Jump to search
(All revisions contained links to *.com, blanking)
m (Reverted edits by MediaWiki spam cleanup (talk) to last revision by 209.49.120.130)
Line 1: Line 1:
 +
{{redirects here|APL programming language family|programming languages that were influenced by APL|Category:APL programming language family}}
 +
{{infobox programming language
 +
| name                  = APL
 +
| paradigm              = [[array programming|array]], [[functional programming|functional]], [[structured programming|structured]], [[modular programming|modular]]
 +
| year                  = 1964
 +
| designer              = [[Kenneth E. Iverson]]
 +
| developer              = [[Kenneth E. Iverson]]
 +
| latest release version =
 +
| latest release date    =
 +
| typing                = [[dynamic typing|dynamic]]
 +
| standards              = ISO8485 (1989), ISO/IEC13751 (2001)
 +
| implementations        = [http://www.dyalog.com/ Dyalog APL], [http://www-306.ibm.com/software/awdtools/apl/ IBM APL2], [http://www.apl2000.com/ APL2000], Sharp APL, [[APLX]], [http://www.nars2000.org/ NARS2000], [http://www.gnu.org/software/apl/ GNU APL]<ref>{{cite web |url=http://directory.fsf.org/wiki/GNU_APL |title=GNU APL|date= |website=directory.fsf.org |publisher=[[Free Software Directory]] |accessdate=28 September 2013}}</ref>
 +
| dialects              = [[A+ (programming language)|A+]], Dyalog APL, APLNext, [http://fastarray.appspot.com/ ELI], [http://www.jsoftware.com/ J]
 +
| influenced_by          = [[mathematical notation]]
 +
| influenced            = [[J (programming language)|J]],<ref name="jinsp">{{cite web|url=http://www.jsoftware.com/jwiki/Essays/Bibliography |title=A Bibliography of APL and J |publisher=Jsoftware.com |date= |accessdate=2010-02-03}}</ref> [[K (programming language)|K]],<ref name="kinsp">{{cite web|url=http://kx.com/Company/press-releases/arthur-interview.php |title=Kx Systems&nbsp;— An Interview with Arthur Whitney&nbsp;— Jan 2004 |publisher=Kx.com |date=2004-01-04 |accessdate=2010-02-03}}</ref> [[Mathematica]], [[MATLAB]],<ref name="mworks">{{cite web|url=http://www.mathworks.com/company/newsletters/news_notes/clevescorner/jan06.pdf |title=The Growth of MatLab&nbsp;— Cleve Moler |format=PDF |date= |accessdate=2010-02-03}}</ref> [[Nial]],<ref name="qinsp">{{cite web|url=http://www.nial.com/AboutQNial.html |title=About Q'Nial |publisher=Nial.com |date= |accessdate=2010-02-03}}</ref> [[Polymorphic Programming Language|PPL]], [[Q (programming language from Kx Systems)|Q]]
 +
}}
 +
{{APLcode}}
 +
[[File:I like APL graphic.jpg|thumb|Promotional material for APL from 1976]]
 +
'''APL''' (named after the book ''A Programming Language'')<ref name="aplbook">{{cite book | last=Iverson | first=Kenneth E. | title=A Programming Language | publisher=Wiley | year=1962 | isbn=0-471-43014-5 | url=http://www.softwarepreservation.org/projects/apl/Physics%20in%20APL2/APROGRAMMING%20LANGUAGE/view}}</ref> is a [[programming language]] developed in the 1960s by [[Kenneth E. Iverson]]. It was an important influence on the development of [[spreadsheet]]s, [[functional programming]],<ref>{{cite web | url=http://awards.acm.org/citation.cfm?id=0703524&srt=all&aw=140&ao=AMTURING | title=ACM Award Citation&nbsp;– John Backus. 1977 | publisher=Awards.acm.org | date = 1924-12-03 | accessdate=2010-02-03}}</ref> and computer math packages.<ref name="mworks" /> It has also inspired several other programming languages.<ref name="jinsp" /><ref name="kinsp" /><ref name="qinsp" /> It is still used today for certain applications.<ref>{{cite web | url=http://www.vector.org.uk/archive/v233/webber.htm | title=APLX version 4&nbsp;– from the viewpoint of an experimental physicist. Vector 23.3 | publisher=Vector.org.uk | date = 2008-05-20 | accessdate=2010-02-03 | archiveurl= http://web.archive.org/web/20100125164250/http://www.vector.org.uk/archive/v233/webber.htm | archivedate= 25 January 2010 }}</ref><ref name="prod">{{Cite journal | title = The future of APL in the insurance world | year = 1999 | journal = ACM SIGAPL APL Quote Quad | issn = 0163–6006 | volume = 30 | issue = 1 | doi = 10.1145/347194.347203 | last1 = Bergquist  | first1 = Gary A. | location = New York, N.Y. | pages = 16–21 }}</ref>
  
 +
== History ==
 +
The first incarnation of what was later to be the APL programming language was published and formalized in ''A Programming Language'',<ref name="aplbook" /> a book describing a notation invented in 1957 by [[Kenneth E. Iverson]] while at [[Harvard University]]. Iverson had developed a [[mathematical notation]] for manipulating arrays that he taught to his students.
 +
 +
Iverson described the premise of the book in the Preface: "Applied mathematics is largely concerned with the design and analysis of explicit procedures for calculating the exact or approximate values of various functions. Such explicit procedures are called algorithms or ''programs''. Because an effective notation for the description of programs exhibits considerable syntactic structure, it is called a ''programming language''."
 +
 +
In 1960, he began work for [[IBM]] and, working with [[Adin Falkoff]], created APL based on the notation he had developed. This notation was used inside IBM for short research reports on computer systems, such as the [[Burroughs B5000]] and its stack mechanism when stack machines versus [[register machine]]s were being evaluated by IBM for upcoming computers.
 +
 +
Also in 1960, Iverson was already using his notation in a draft copy of Chapter 6 called "A programming language" for the book he was writing with [[Fred Brooks]], ''Automatic Data Processing'', which would later be published in 1963.<ref>Iverson, Kenneth E., [http://www.softwarepreservation.org/projects/apl/book/Iverson-AutomaticDataProcessing-color.pdf/view "Automatic Data Processing: Chapter 6: A programming language"], 1960, DRAFT copy for Brooks and Iverson 1963 book, "Automatic Data Processing".</ref><ref>[[Fred Brooks|Brooks, Fred]]; Iverson, Kenneth, (1963), ''Automatic Data Processing'', John Wiley & Sons Inc.</ref>
 +
 +
Published in 1962, the notation described in ''A Programming Language''<ref name="aplbook" /> was recognizable yet distinct from later APL.
 +
 +
As early as 1962, the first attempt to use the notation to describe a complete computer system happened after Falkoff discussed with Dr. William C. Carter his work in the standardization of the instruction set for the machines that later became the [[IBM System/360]] family.
 +
 +
In 1963, Dr. Herbert Hellerman, working at the IBM Systems Research Institute, implemented a part of the notation on an [[IBM 1620]] computer, and it was used by students in a special high school course on calculating transcendental functions by series summation. Students tested their code in Dr. Hellerman's lab. This implementation of a portion of the notation was called PAT (Personalized Array Translator).<ref>Hellerman, H., "Experimental Personalized Array Translator System", ''Communications of the ACM'', 7, 433 (July, 1964).</ref>
 +
 +
In 1963, Falkoff, Iverson, and [[Edward H. Sussenguth Jr.]], all working at IBM, used the notation for a formal description of the [[IBM System/360]] series machine architecture and functionality, which resulted in a paper published in IBM Systems Journal in 1964. After this was published, the team turned their attention to an implementation of the notation on a computer system. One of the motivations for this focus of implementation was the interest of John L. Lawrence who had new duties with [[Science Research Associates]], an educational company bought by IBM in 1964. Lawrence asked Iverson and his group to help utilize the language as a tool for the development and use of computers in education.<ref>Falkoff, Adin D.; Iverson, Kenneth E., [http://www.jsoftware.com/papers/APLEvol.htm "The Evolution of APL"], ACM SIGPLAN Notices 13, 1978-08.</ref>
 +
 +
After [[Lawrence M. Breed]] and [[Philip S. Abrams]] of Stanford University joined the team at IBM Research, they continued their prior work on an implementation programmed in [[FORTRAN IV]] for a portion of the notation was done for the [[IBM 7090]] computer running under the [[IBM 7090/94 IBSYS|IBSYS]] operating system. This work was finished in late 1965 and later known as IVSYS (Iverson System). The basis of this implementation was described in detail by Abrams in a Stanford University Technical Report, "An Interpreter for Iverson Notation" in 1966.<ref>Abrams, Philip S., [http://infolab.stanford.edu/TR/CS-TR-66-47.html ''An interpreter for "Iverson notation"''], Technical Report: CS-TR-66-47, Department of Computer Science, Stanford University, August 1966.</ref> Like Hellerman's PAT system earlier, this implementation did not include the APL character set but used special English reserved words for functions and operators. The system was later adapted for a time-sharing system and, by November 1966, it had been reprogrammed for the IBM/360 Model 50 computer running in a time sharing mode and was used internally at IBM.<ref>Haigh, Thomas, "Biographies: Kenneth E. Iverson", ''IEEE Annals of the History of Computing'', 2005</ref>
 +
 +
[[File:IBM Selectric Globe Wiki.jpg|thumb|IBM typeballs (one OCR) with clip, {{€|2}} coin for scale]]
 +
 +
A key development in the ability to use APL effectively, before the widespread use of CRT terminals, was the development of a special [[IBM Selectric typewriter]] interchangeable typeball with all the special APL characters on it. This was used on paper printing terminal workstations using the Selectric typewriter and typeball mechanism, such as the [[IBM 1050]] and [[IBM 2741]] terminal. Keycaps could be placed over the normal keys to show which APL characters would be entered and typed when that key was struck. For the first time, a programmer could actually type in and see real APL characters as used in Iverson's notation and not be forced to use awkward English keyword representations of them. Falkoff and Iverson had the special APL Selectric typeballs, 987 and 988, designed in late 1964, although no APL computer system was available to use them.<ref name="APLQQ91">Breed, Larry, [http://portal.acm.org/citation.cfm?id=138094.140933 "The First APL Terminal Session"], ''APL Quote Quad'', Association for Computing Machinery, Volume 22, Number 1, September 1991, p.2-4.</ref> Iverson cited Falkoff as the inspiration for the idea of using an IBM Selectric typeball for the APL character set.<ref>[http://www.computerhistory.org/tdih/?setdate=19/12/2009 Adin Falkoff] - Computer History Museum. "Iverson credited him for choosing the name APL and the introduction of the IBM golf-ball typewriter with the replacement typehead, which provided the famous character set to represent programs."</ref>
 +
 +
[[File:APL-keybd2.svg|thumb|center|600px|A programmer's view of the IBM 2741 keyboard layout with the APL typeball print head inserted]]
 +
 +
Some APL symbols, even with the APL characters on the typeball, still had to be typed in by over-striking two existing typeball characters. An example would be the "grade up" character, which had to be made from a "delta" (shift-H) and a "[[Sheffer stroke]]" (shift-M). This was necessary because the APL character set was larger than the 88 characters allowed on the Selectric typeball.
 +
 +
The first APL interactive login and creation of an APL workspace was in 1966 by Larry Breed using an IBM 1050 terminal at the IBM Mohansic Labs near [[Thomas J. Watson Research Center]], the home of APL, in [[Yorktown Heights, New York]].<ref name="APLQQ91"/>
 +
 +
IBM was chiefly responsible for the introduction of APL to the marketplace. APL was first available in 1967 for the [[IBM 1130]] as ''APL\1130''.<ref>{{cite journal | url=http://www.vector.org.uk/archive/v223/APL_1130.htm | title=How We Got to APL\1130 | author=Larry Breed | authorlink=Larry Breed | journal=Vector (British APL Association) | volume=22 | issue=3 |date=August 2006 | issn=0955-1433 }}</ref><ref>[http://bitsavers.org/pdf/ibm/1130/lang/1130-03.3.001_APL_1130_May69.pdf APL\1130 Manual], May 1969</ref> It would run in as little as 8k 16-bit words of memory, and used a dedicated 1 megabyte hard disk.
 +
 +
APL gained its foothold on mainframe timesharing systems from the late 1960s through the early 1980s, in part because it would run on lower-specification systems that were not equipped with [[Dynamic Address Translation]] hardware.<ref>{{cite web|url=http://www.quadibloc.com/comp/aplint.htm |title=Remembering APL |publisher=Quadibloc.com |date= |accessdate=2013-06-17}}</ref> Additional improvements in performance for selected [[IBM System/370]] mainframe systems included the "APL Assist Microcode" in which some support for APL execution was included in the actual firmware as opposed to APL being exclusively a software product. Somewhat later, as suitably performing hardware was finally becoming available in the mid- to late-1980s, many users migrated their applications to the personal computer environment.
 +
 +
Early IBM APL interpreters for IBM 360 and IBM 370 hardware implemented their own multi-user management instead of relying on the host services, thus they were timesharing systems in their own right. First introduced in 1966, the ''APL\360''<ref name="IBM APL\360 1968">Falkoff, Adin; Iverson, Kenneth E., [http://bitsavers.org/pdf/ibm/apl/APL_360_Users_Manual_Aug68.pdf "APL\360 Users Guide"], IBM Research, Thomas J. Watson Research Center, Yorktown Heights, NY, August 1968.</ref><ref>[http://bitsavers.org/pdf/ibm/apl/APL_360_Terminal_System_Mar67.pdf "APL\360 Terminal System"], IBM Research, Thomas J. Watson Research Center, March 1967.</ref><ref name="apl360">{{cite book | last=Pakin | first=Sandra | title=APL\360 Reference Manual | publisher=Science Research Associates, Inc. | year=1968 | isbn=0-574-16135-X}}</ref> system was a multi-user interpreter. The ability to programmatically communicate with the operating system for information and setting interpreter system variables was done through special privileged "I-beam" functions, using both monadic and dyadic operations.<ref>Falkoff, Adin D.; Iverson, Kenneth E.,[http://www.research.ibm.com/journal/rd/174/ibmrd1704F.pdf ''The Design of APL''], ''IBM Journal of Research and Development'', Volume 17, Number 4, July 1973. "These environmental defined functions were based on the use of still another class of functions—called "I-beams" because of the shape of the symbol used for them—which provide a more general facility for communication between APL programs and the less abstract parts of the system. The I-beam functions were first introduced by the system programmers to allow them to execute System/360 instructions from within APL programs, and thus use APL as a direct aid in their programming activity. The obvious convenience of functions of this kind, which appeared to be part of the language, led to the introduction of the monadic I-beam function for direct use by anyone. Various arguments to this function yielded information about the environment such as available space and time of day."</ref>
 +
 +
In 1973, IBM released ''APL.SV'', which was a continuation of the same product, but which offered [[shared variable]]s as a means to access facilities outside of the APL system, such as operating system files. In the mid-1970s, the IBM mainframe interpreter was even adapted for use on the [[IBM 5100]] desktop computer, which had a small CRT and an APL keyboard, when most other small computers of the time only offered [[BASIC]]. In the 1980s, the ''VSAPL'' program product enjoyed widespread usage with [[Conversational Monitor System|CMS]], [[Time Sharing Option|TSO]], [[VSPC]], [[MUSIC/SP]] and [[CICS]] users.
 +
 +
In 1973-1974, Dr. Patrick E. Hagerty directed the implementation of the University of Maryland APL interpreter for the [[UNIVAC 1100/2200 series|Sperry Univac 1100]] Series mainframe computers.<ref>{{cite web | last=Minker | first=Jack | title=Beginning of Computing and Computer Sciences at the University of Maryland | url=http://www.cs.umd.edu/department/dept-history/minker-report.pdf | publisher=University of Maryland | accessdate=23 May 2011 | location=Section 2.3.4 | page=38 | format=PDF |date=January 2004 | archiveurl= http://web.archive.org/web/20110610064807/http://www.cs.umd.edu/department/dept-history/minker-report.pdf | archivedate= 10 June 2011 }}</ref> At the time, Sperry had nothing. In 1974, student Alan Stebbens was assigned the task of implementing an internal function.<ref>{{cite web | last=Stebbens | first=Alan | title=How it all began | url=http://lathwellproductions.ca/wordpress/film-synopsis/comments-from-linkedin/#comment-15 | publisher=LinkedIn | accessdate=22 May 2011}}</ref>
 +
 +
Several timesharing firms sprang up in the 1960s and 1970s that sold APL services using modified versions of the IBM APL\360<ref name="apl360" /> interpreter. In North America, the better-known ones were [[I. P. Sharp Associates]], [[Scientific Time Sharing Corporation|STSC]], and [[The Computer Company]] (TCC). With the advent first of less expensive mainframes such as the [[IBM 4300]] and later the personal computer, the timesharing industry had all but disappeared by the mid-1980s.
 +
 +
''Sharp APL'' was available from [[I. P. Sharp Associates]], first on a timesharing basis in the 1960s, and later as a program product starting around 1979. ''Sharp APL'' was an advanced APL implementation with many language extensions, such as ''packages'' (the ability to put one or more objects into a single variable), file system, nested arrays, and [[shared variable]]s.
 +
 +
APL interpreters were available from other mainframe and mini-computer manufacturers as well, notably [[Burroughs Corporation|Burroughs]], [[Control Data Corporation|CDC]], [[Data General]], [[Digital Equipment Corporation|DEC]], [[Harris Corporation|Harris]], [[Hewlett-Packard]], [[Siemens AG]], [[Xerox]], and others.
 +
 +
[[Garth Foster]] of [[Syracuse University]] sponsored regular meetings of the APL implementers' community at Syracuse's Minnowbrook Conference Center in rural upstate [[New York State|New York]]. In later years, Eugene McDonnell organized similar meetings at the [[Asilomar Conference Grounds]] near Monterey, California, and at Pajaro Dunes near Watsonville, California. The SIGAPL special interest group of the [[Association for Computing Machinery]] continues to support the APL community.<ref>{{cite web|url=http://www.sigapl.org/ |title=SIGAPL Home Page |publisher=Sigapl.org |date= |accessdate=2013-06-17}}</ref>
 +
 +
In 1979, Iverson received the [[Turing Award]] for his work on APL.<ref>{{cite web | url=http://awards.acm.org/citation.cfm?id=9147499&srt=all&aw=140&ao=AMTURING | title=Turing Award Citation 1979 | publisher=Awards.acm.org | accessdate=2010-02-03}}</ref>
 +
 +
=== APL2 ===
 +
Starting in the early 1980s, IBM APL development, under the leadership of Dr [[Jim Brown (Computer Scientist)|Jim Brown]], implemented a new version of the APL language that contained as its primary enhancement the concept of ''nested arrays'', where an array can contain other arrays, as well as new language features which facilitated the integration of nested arrays into program workflow. Ken Iverson, no longer in control of the development of the APL language, left IBM and joined [[I. P. Sharp Associates]], where one of his major contributions was directing the evolution of Sharp APL to be more in accordance with his vision.{{Citation needed|date=April 2010}}
 +
 +
As other vendors were busy developing APL interpreters for new hardware, notably [[Unix]]-based [[microcomputer]]s, APL2 was almost always the standard chosen for new APL interpreter developments. Even today, most APL vendors cite APL2 compatibility, which only approaches 100%, as a selling point for their products.{{Citation needed|date=April 2010}}
 +
 +
''APL2'' for IBM mainframe computers is still available as of 2013-07-29,<ref>{{cite web|title=A programming language for problem solving, visualization and database access|url=http://www-03.ibm.com/software/products/us/en/apl2|accessdate=29 July 2013}}</ref> and was first available for [[Conversational Monitor System|CMS]] and [[Time Sharing Option|TSO]] in 1984.<ref>{{cite journal | url=http://www.research.ibm.com/journal/sj/304/ibmsj3004C.pdf | title=The IBM family of APL systems | first=Adin D. | last=Falkoff | year=1991 | journal=IBM Systems Journal | volume=30 | issue=4 | pages=416–432 | publisher=[[IBM]] | format=PDF | accessdate=2009-06-13 | doi=10.1147/sj.304.0416}}</ref> The APL2 Workstation edition (Windows, OS/2, AIX, Linux, and Solaris) followed much later in the early 1990s.{{Citation needed|date=April 2010}}
 +
 +
=== Microcomputers ===
 +
The first microcomputer implementation of APL was on the [[Intel 8008]]-based [[MCM/70]], the first general purpose personal computer, in 1973.
 +
 +
IBM's own [[IBM 5100]] microcomputer (1975) offered APL as one of two built-in ROM-based interpreted languages for the computer, complete with a keyboard and display that supported all the special symbols used in the language.
 +
 +
In 1976 DNA Systems introduced an APL interpreter for their TSO Operating System, which ran timesharing on the IBM 1130, Digital Scientific Meta-4, General Automation GA 18/30 and Computer Hardware CHI 21/30.
 +
 +
The [[VideoBrain Family Computer]], released in 1977, only had one programming language available for it, and that was a dialect of APL called APL/S.<ref>[http://books.google.com/books?id=OQEAAAAAMBAJ&pg=PA133&lpg=PA133&dq=videobrain+family+computer+apl/s&source=bl&ots=_tmStYA0UG&sig=mxb5bqgWuA_NBVww1ywhpA1iNWY&hl=en&ei=rleIS8_hPN2mtgez8vi0DQ&sa=X&oi=book_result&ct=result&resnum=5&ved=0CBQQ6AEwBA#v=onepage&q=videobrain%20family%20computer%20apl%2Fs&f=false "VideoBrain Family Computer"], ''[[Popular Science]]'', November 1978, advertisement.</ref>
 +
 +
A Small APL for the [[Intel]] 8080 called EMPL was released in 1977, and Softronics APL, with most of the functions of full APL, for 8080-based CP/M systems was released in 1979.
 +
 +
In 1977, the Canadian firm Telecompute Integrated Systems, Inc. released a business-oriented APL interpreter known as TIS APL, for Z80-based systems. It featured the full set of file functions for APL, plus a full screen input and switching of right and left arguments for most dyadic operators by introducing the <code>~.</code> prefix to all single character dyadic functions such as <code>-</code> or <code>/</code>.
 +
 +
Vanguard APL was available for [[Z80]] [[CP/M]]-based processors in the late 1970s. [[The Computer Company|TCC]] released APL.68000 in the early 1980s for Motorola [[68000]]-based processors, this system being the basis for MicroAPL Limited's [[APLX]] product. I. P. Sharp Associates released a version of their APL interpreter for the [[IBM PC]] and [[PC/370]].<ref>Higgins, Donald S., [http://portal.acm.org/citation.cfm?id=382167.383025 "PC/370 virtual machine"], ''ACM SIGSMALL/PC Notes'', Volume 11, Issue 3 (August 1985), pp.23 - 28, 1985.</ref> For the IBM PC, an [[emulator]] was written that facilitated reusing much of the IBM 370 mainframe code. Arguably, the best known APL interpreter for the IBM Personal Computer was [[Scientific Time Sharing Corporation|STSC]]'s APL*Plus/PC.{{citation needed|date=December 2012}}
 +
 +
The [[Commodore SuperPET]], introduced in 1981, included an APL interpreter developed by the [[University of Waterloo]].
 +
 +
In the early 1980s, the Analogic Corporation developed ''The APL Machine'', which was an [[vector processor|array processing]] computer designed to be programmed only in APL. There were actually three processing units, the user's workstation, an [[IBM PC]], where programs were entered and edited, a [[Motorola 68000]] processor that ran the APL interpreter, and the Analogic array processor that executed the primitives.<ref>[http://groups.yahoo.com/group/apl-l/message/8180],''Yahoo! Group APL-L'', April, 2003</ref> At the time of its introduction, The APL Machine was likely the fastest APL system available. Although a technological success, The APL Machine was a marketing failure. The initial version supported a single process at a time. At the time the project was discontinued, the design had been completed to allow multiple users. As an aside, an unusual aspect of The APL Machine was that the library of workspaces was organized such that a single function or variable that was shared by many workspaces existed only once in the library. Several of the members of The APL Machine project had previously spent a number of years with Burroughs implementing ''APL\700''.
 +
 +
At one stage, it was claimed by Bill Gates in his [[Open Letter to Hobbyists]], [[Microsoft Corporation]] planned to release a version of APL, but these plans never materialized.
 +
 +
An early 1978 publication of [[Rodnay Zaks]] from [[Sybex]] was ''A microprogrammed APL implementation'' ISBN 0-89588-005-9, which is the complete source listing for the microcode for a Digital Scientific Corporation Meta 4 microprogrammable processor implementing APL. This topic was also the subject of his PhD thesis.<ref>Zaks, Rodnay, "A Microprogrammed APL Implementation,", Ph.D. Thesis, University of California, Berkeley, June 1972.</ref><ref>Zaks, Rodnay, "Microprogrammed APL,", Fifth IEEE Computer Conference Proceedings, Sep. 1971 p 193</ref>
 +
 +
In 1979, [[William Yerazunis]] wrote a partial version of APL in [[Prime Computer]] FORTRAN, extended it with graphics primitives, and released it. This was also the subject of his Masters thesis.<ref>{{cite web | url=http://opac.lib.rpi.edu/search~S6?/Xa:%28yerazunis%29&m=t&m=r&m=g&m=a&m=o&SORT=D&searchscope=6/Xa:%28yerazunis%29&m=t&m=r&m=g&m=a&m=o&SORT=D&searchscope=6&SUBKEY=a%3A%28yerazunis%29/1%2C14%2C14%2CB/frameset&FF=Xa:%28yerazunis%29&m=t&m=r&m=g&m=a&m=o&SORT=D&searchscope=6&2%2C2%2C | title=A Partial Implementation of APL with Graphics Primitives for PRIME Computers | author=William Yerazunis | accessdate=2013-08-14 }}</ref>
 +
 +
=== Extensions ===
 +
Recent extensions to APL include:
 +
* [[Object-oriented programming]]<ref name="APLX : New features in Version 5">{{cite web | url=http://www.microapl.co.uk/apl/aplxv5.html | title=APLX : New features in Version 5 | publisher=Microapl.co.uk | date = 2009-04-01 | accessdate=2010-02-03 | archiveurl= http://web.archive.org/web/20100106160559/http://www.microapl.co.uk/apl/aplxv5.html | archivedate= 6 January 2010 }}</ref>
 +
* Support for [[.NET Framework|.NET]],<ref name="APLX : New features in Version 5" /> ActiveX,<ref>{{cite web | url=http://www.apl2000.com/netaccess.php | title=APL2000 NetAccess | publisher=Apl2000.com | accessdate=2010-02-03}}</ref> operating system resources & connectivity
 +
* APL as a native .NET language using Visual Studio 2008<ref>{{cite web | url=http://www.visualapl.com/library/aplnext/Visual_APLNext.htm | title=Introduction to Visual APL | publisher=Visualapl.com | accessdate=2010-02-03}}</ref>
 +
* Integrated charting<ref>{{cite web | url=http://www.dyalog.com/version12.html | title=Dyalog Built-in Charting | publisher=Dyalog.com | accessdate=2010-02-03 | archiveurl= http://web.archive.org/web/20100203150500/http://www.dyalog.com/version12.html | archivedate= 3 February 2010 }}</ref> and manipulation of SQL databases
 +
* XML-array conversion primitives<ref name="APLX : New features in Version 5" /><ref>{{cite web | url=http://www.dyalog.com/help/12.1/html/xml%20convert.htm | title=XML-to-APL Conversion tool in Dyalog APL and APLX | publisher=Dyalog.com | accessdate=2010-02-03}}</ref>
 +
* [[Lambda expressions]]<ref>{{cite web | url=http://www.dyalog.com/download/dfns.pdf | title=Dynamic Functions in Dyalog APL&nbsp;— John Scholes. 1997 | format=PDF | accessdate=2010-02-03}}</ref>
 +
 +
== Design ==
 +
{{unreferenced section|date=December 2012}}
 +
{{tone|section|date=January 2012}}
 +
 +
Unlike traditionally structured programming languages, code in APL is typically structured as chains of [[unary operation|monadic]] or [[binary operation|dyadic]] [[function (programming)|functions]] and [[higher-order function|operators]] acting on [[array data type|arrays]]. As APL has many nonstandard ''primitives'' (functions and operators, indicated by a single symbol or a combination of a few symbols), it does not have function or [[operator precedence]]. Early APL implementations did not have [[control flow|control structures]] (do or while loops, if-then-else), but by using array operations, use of [[structured programming]] constructs was not necessary, as an operation was carried out on all the elements of the array in a single statement. For example, the iota (ι) function (ιN yields a one-dimensional array, or vector, 1 2 3 ... N) can replace for-loop [[iteration]]. More recent implementations of APL generally include comprehensive control structures, so that data structure and program control flow can be clearly and cleanly separated.
 +
 +
The APL environment is called a ''workspace''. In a workspace the user can define programs and data, i.e. the data values exist also outside the programs, and the user can manipulate the data without the necessity to define a program. For example,
 +
 +
<pre>
 +
N ← 4 5 6 7
 +
</pre>
 +
 +
assigns the [[coordinate vector|vector]] value 4 5 6 7 to N;
 +
 +
<pre>
 +
N+4
 +
</pre>
 +
 +
adds 4 to all elements of the vector (giving 8 9 10 11) and prints them (a return value not assigned at the end of a statement to a variable using the assignment arrow <math>\leftarrow </math> is displayed by the APL interpreter);
 +
 +
<pre>
 +
+/N
 +
</pre>
 +
 +
prints the sum of N, i.e. 22.
 +
 +
These operations can then be combined in a single statement, e.g.
 +
<pre>
 +
m ← +/ιn
 +
</pre>
 +
 +
assigns to m the scalar value n(n+1)/2, i.e. <math>\displaystyle\sum\limits_{i=1}^n i</math>.
 +
 +
The user can save the workspace with all values, programs and execution status.
 +
 +
APL is well known for its use of a set of non-[[ASCII]] symbols, which are an extension of traditional arithmetic and algebraic notation. Having single character names for [[SIMD]] vector functions is one way that APL enables compact formulation of algorithms for data transformation such as computing [[Conway's Game of Life]] in one line of code.<ref>{{cite web|url=http://catpad.net/michael/apl |title=example |publisher=Catpad.net |date= |accessdate=2013-06-17}}</ref> In nearly all versions of APL, it is theoretically possible to express any computable function in one expression, that is, in one line of code.{{citation needed|date=December 2012}}
 +
 +
Because of the unusual [[character set]], many programmers use special [[computer keyboard|keyboards]] with APL keytops for authoring APL code. Although there are various ways to write APL code using only ASCII characters,<ref>[http://www.math.uwaterloo.ca/apl_archives/apl/translit.schemes Dickey, Lee, A list of APL Transliteration Schemes], 1993</ref> in practice, it is almost never done. (This may be thought to support Iverson's thesis about [[Linguistic relativity|notation as a tool of thought]].)<ref>Iverson K.E.,
 +
"[http://www.jsoftware.com/papers/tot.htm Notation as a Tool of Thought]", ''Communications of the ACM'', 23: 444-465 (August 1980).</ref> Most if not all modern implementations use standard keyboard layouts, with special mappings or [[input method editor]]s to access non-ASCII characters. Historically, the APL font has been distinctive, with uppercase italic alphabetic characters and upright numerals and symbols. Most vendors continue to display the APL character set in a custom font.
 +
 +
Advocates of APL{{who|date=October 2012}} claim that the examples of so-called write-only code are almost invariably examples of poor programming practice or novice mistakes, which can occur in any language. Advocates of APL also claim that they are far more productive with APL than with more conventional computer languages, and that working software can be implemented in far less time and with far fewer programmers than using other technology. APL lets an individual solve harder problems faster. Also, being compact and terse, APL lends itself well to larger scale software development as complexity arising from a large number of lines of code can be dramatically reduced. Many APL advocates and practitioners view programming in standard programming languages, such as [[COBOL]] and [[Java (programming language)|Java]], as comparatively tedious. APL is often found where time-to-market is important, such as with trading systems. {{citation needed|date=March 2013}}
 +
 +
Iverson later designed the [[J programming language]], which uses [[ASCII]] with [[digraph (computing)|digraphs]] instead of special symbols.
 +
 +
== Execution ==
 +
{{unreferenced section|date=December 2012}}
 +
 +
=== Interpreters ===
 +
APLNext (formerly APL2000) offers an advanced APL interpreter that operates under Linux, Unix, and Windows. It supports Windows automation, supports calls to operating system and user defined DLLs, has an advanced APL File System, and represents the current level of APL language development. APL2000's product is an advanced continuation of [[Scientific Time Sharing Corporation|STSC]]'s successful APL*Plus/PC and APL*Plus/386 product line.
 +
 +
''Dyalog APL'' is an advanced APL interpreter that operates under Linux, Unix, and Windows. Dyalog has innovative extensions to the APL language, which include new [[Object-oriented programming|object-oriented]] features, numerous language enhancements, plus a consistent [[namespace]] model used for both its Microsoft Automation interface, as well as native namespaces. For the Windows platform, Dyalog APL offers tight integration with .NET, plus limited integration with the Microsoft Visual Studio development platform.
 +
 +
IBM offers a version of IBM APL2 for IBM AIX, Linux, Sun Solaris and Windows systems. This product is a continuation of APL2 offered for IBM mainframes. IBM APL2 was arguably the most influential APL system, which provided a solid implementation standard for the next set of extensions to the language, focusing on nested arrays.
 +
 +
NARS2000 is an open source APL interpreter written by Bob Smith, a well-known APL developer and implementor from [[STSC]] in the 1970s and 1980s. NARS2000 contains advanced features and new datatypes, runs natively under Windows (32- and 64-bit versions), and runs under [[Linux]] and Apple [[Mac OS]] with [[Wine (software)|Wine]].
 +
 +
MicroAPL Limited offers [[APLX]], a full-featured 64 bit interpreter for [[Linux]], [[Microsoft Windows]], and [[Mac OS]] systems. The core language is closely modelled on IBM's APL2 with various enhancements. ''APLX'' includes close integration with .NET, Java, Ruby and R.
 +
 +
[[Soliton Incorporated]] offers the SAX interpreter (Sharp APL for Unix) for Unix and Linux systems, which is a further development of I. P. Sharp Associates' Sharp APL product. Unlike most other APL interpreters, [[Kenneth E. Iverson]] had some influence in the way nested arrays were implemented in Sharp APL and SAX. Nearly all other APL implementations followed the course set by IBM with APL2, thus some important details in Sharp APL differ from other implementations.
 +
 +
OpenAPL is an open source implementation of APL published by Branko Bratkovic, based on code by [[Ken Thompson]] of Bell Laboratories, together with contributions by others. It is licensed under the [[GNU General Public License]], and runs on Unix systems including Linux on x86, SPARC and other CPUs.
 +
 +
[http://www.gnu.org/software/apl GNU APL] is a free implementation of ISO Standard 13751 and hence similar to APL2. It runs on GNU/Linux and on Windows using [[Cygwin]]. It uses Unicode internally. GNU APL was written by Jürgen Sauermann.
 +
 +
=== Compilers ===
 +
APL programs are normally [[interpreted language|interpreted]] and less often [[compiled language|compiled]]. In reality, most APL compilers [[translated]] source APL to a lower level language such as [[C (programming language)|C]], leaving the machine-specific details to the lower level compiler. Compilation of APL programs was a frequently discussed topic in conferences. Although some of the newer enhancements to the APL language such as nested arrays have rendered the language increasingly difficult to compile, the idea of APL compilation is still under development today.
 +
 +
In the past, APL compilation was regarded as a means to achieve execution speed comparable to other mainstream languages, especially on mainframe computers.
 +
Several APL compilers achieved some levels of success, though comparatively little of the development effort spent on APL over the years went to perfecting compilation into machine code.
 +
 +
As is the case when moving APL programs from one vendor's APL interpreter to another, APL programs invariably will require changes to their content. Depending on the compiler, variable declarations might be needed, certain language features would need to be removed or avoided, or the APL programs would need to be cleaned up in some way. Some features of the language, such as the execute function (an expression evaluator) and the various [[reflection (computer science)|reflection]] and [[introspection (computer science)|introspection]] functions from APL, such as the ability to return a function's text or to materialize a new function from text, are simply not practical to implement in machine code compilation.
 +
 +
A commercial compiler was brought to market by [[Scientific Time Sharing Corporation|STSC]] in the mid-1980s as an add-on to IBM's VSAPL Program Product. Unlike more modern APL compilers, this product produced machine code that would execute only in the interpreter environment, it was not possible to eliminate the interpreter component. The compiler could compile many scalar and vector operations to machine code, but it would rely on the APL interpreter's services to perform some more advanced functions, rather than attempt to compile them. However, dramatic speedups did occur, especially for heavily iterative APL code.
 +
 +
Around the same time, the book ''[[An APL Compiler]]'' by [[Timothy Budd]] appeared in print. This book detailed the construction of an APL translator, written in [[C (programming language)|C]], which performed certain optimizations such as [[loop fusion]] specific to the needs of an array language. The source language was APL-like in that a few rules of the APL language were changed or relaxed to permit more efficient compilation. The translator would emit C code which could then be compiled and run well outside of the APL workspace.
 +
 +
Today, execution speed is less critical and many popular languages are implemented using [[virtual machine]]s: instructions that are interpreted at runtime. The Burroughs/Unisys ''APLB'' interpreter (1982) was the first to use dynamic incremental compilation to produce code for an APL-specific virtual machine. It recompiled on-the-fly as identifiers changed their functional meanings. In addition to removing [[parsing]] and some error checking from the main execution path, such compilation also streamlines the repeated entry and exit of user-defined functional operands. This avoids the stack setup and take-down for function calls made by APL's built-in operators such as Reduce and Each.
 +
 +
''APEX'', a research APL compiler, is available from [[Snake Island Research Inc]]. APEX compiles flat APL (a subset of ISO N8485) into [[SAC (programming language)|SAC]], a functional array language with parallel semantics, and currently runs under [[Linux]]. APEX-generated code uses [[loop fusion]] and [[array contraction]], special-case algorithms not generally available to interpreters (e.g., upgrade of [[permutation vector]]), to achieve a level of performance comparable to that of [[Fortran]].
 +
 +
The APLNext ''VisualAPL'' system is a departure from a conventional APL system in that VisualAPL is a true .NET language which is fully interoperable with other .NET languages such as [[VB.NET]] and [[C Sharp (programming language)|C#]]. VisualAPL is inherently object oriented and Unicode-based. While VisualAPL incorporates most of the features of standard APL implementations, the VisualAPL language extends standard APL to be .NET-compliant. VisualAPL is hosted in the standard Microsoft Visual Studio IDE and as such, invokes compilation in a manner identical to that of other .NET languages. By producing [[Common Intermediate Language]] (CIL) code, it utilizes the Microsoft just-in-time compiler (JIT) to support 32-bit or 64-bit hardware. Substantial performance speed-ups over standard APL have been reported,{{Citation needed|date=September 2009}} especially when (optional) strong typing of function arguments is used.
 +
 +
An APL to [[C Sharp (programming language)|C#]] translator is available from [[Causeway Graphical Systems]]. This product was designed to allow the APL code, translated to equivalent C#, to run completely outside of the APL environment. The Causeway compiler requires a run-time library of array functions. Some speedup, sometimes dramatic, is visible, but happens on account of the optimisations inherent in Microsoft's .NET Framework.
 +
 +
=== Matrix optimizations ===
 +
{{unreferenced section|date=December 2012}}
 +
 +
APL was unique in the speed with which it could perform complicated matrix operations. For example, a very large matrix multiplication would take only a few seconds on a machine that was much less powerful than those today.{{Citation needed|date=June 2010}} There were both technical and economic reasons for this advantage:
 +
* Commercial interpreters delivered highly tuned linear algebra library routines.
 +
* Very low interpretive overhead was incurred per-array—not per-element.
 +
* APL response time compared favorably to the runtimes of early optimizing compilers.
 +
* IBM provided [[microcode]] assist for APL on a number of IBM/370 mainframes.
 +
 +
Phil Abrams' much-cited paper "An APL Machine" illustrated how APL could make effective use of [[lazy evaluation]] where calculations would not actually be performed until the results were needed and then only those calculations strictly required. An obvious (and easy to implement) lazy evaluation is the ''J-vector'': when a monadic ''iota'' is encountered in the code, it is kept as a representation instead of being expanded in memory; in future operations, a ''J-vector'''s contents are the loop's induction register, not reads from memory.
 +
 +
Although such techniques were not widely used by commercial interpreters, they exemplify the language's best survival mechanism: not specifying the order of scalar operations or the exact contents of memory. As standardized, in 1983 by [[American National Standards Institute|ANSI]] [[working group]] X3J10, APL remains highly [[data parallelism|data-parallel]]. This gives language implementers immense freedom to schedule operations as efficiently as possible. As computer innovations such as [[cache memory]], and [[SIMD]] execution became commercially available, APL programs are ported with almost no extra effort spent re-optimizing low-level details.
 +
 +
== Terminology ==
 +
{{unreferenced section|date=December 2012}}
 +
 +
APL makes a clear distinction between ''functions'' and ''operators''. Functions take arrays (variables or constants or expressions) as arguments, and return arrays as results. Operators (similar to [[higher-order function]]s) take functions or arrays as arguments, and derive related functions. For example the "sum" function is derived by applying the "reduction" operator to the "addition" function. Applying the same reduction operator to the "maximum" function (which returns the larger of two numbers) derives a function which returns the largest of a group (vector) of numbers. In the J language, Iverson substituted the terms "verb" for "function"  and "adverb" or "conjunction" for  "operator".
 +
 +
APL also identifies those features built into the language, and represented by a symbol, or a fixed combination of symbols, as ''primitives''. Most primitives are either functions or operators. Coding APL is largely a process of writing non-primitive functions and (in some versions of APL) operators. However a few primitives are considered to be neither functions nor operators, most noticeably assignment.
 +
 +
Some words used in APL literature have meanings that differ from those in both mathematics and the generality of computer science.
 +
 +
{| class="wikitable"
 +
|-
 +
! Term
 +
! Description
 +
|-
 +
! function
 +
| operation or mapping that takes zero, one (right) or two (left & right) array valued arguments and may return an array valued result. A function may be:
 +
* Primitive: built-in and represented by a single glyph;<ref name="aplxch6">{{cite web | url=http://www.microapl.co.uk/APL/apl_concepts_chapter6.html | title=APL concepts | publisher=Microapl.co.uk | accessdate=2010-02-03}}</ref>
 +
* Defined: as a named and ordered collection of program statements;<ref name="aplxch6" />
 +
* Derived: as a combination of an operator with its arguments.<ref name="aplxch6" />
 +
|-
 +
! array
 +
| data valued object of zero or more [[orthogonal]] dimensions in [[row major|row-major]] order in which each item is a primitive scalar datum or another array.<ref>{{cite web | url=http://www.nial.com/ArrayTheory.html | title=Nested array theory | publisher=Nial.com | accessdate=2010-02-03}}</ref>
 +
|-
 +
! niladic
 +
| not taking or requiring any arguments,<ref name="Bohman_Froberg">"Programmera i APL", Bohman, Fröberg, Studentlitteratur, ISBN 91-44-13162-3</ref>
 +
|-
 +
! monadic
 +
| requiring only one argument; on the right for a function, on the left for an operator, unary<ref name="Bohman_Froberg" />
 +
|-
 +
! dyadic
 +
| requiring both a left and a right argument, binary<ref name="Bohman_Froberg" />
 +
|-
 +
! ambivalent or nomadic
 +
| capable of use in a monadic or dyadic context, permitting its left argument to be elided<ref name="aplxch6" />
 +
|-
 +
! operator
 +
| operation or mapping that takes one (left) or two (left & right) function or array valued arguments (operands) and derives a function. An operator may be:
 +
* Primitive: built-in and represented by a single glyph;<ref name="aplxch6" />
 +
* Defined: as a named and ordered collection of program statements.<ref name="aplxch6" />
 +
|}
 +
 +
== Syntax ==
 +
{{unreferenced section|date=December 2012}}
 +
 +
{{Main|APL syntax and symbols}}
 +
 +
== Examples ==
 +
{{unreferenced section|date=December 2012}}
 +
 +
This displays "Hello, world":
 +
 +
<pre>
 +
'Hello, world'
 +
</pre>
 +
 +
A design theme in APL is to define default actions in some cases that would be syntax errors in their equivalent forms in most other programming languages. APL is economical in its character usage.
 +
 +
The 'Hello, world' string constant above displays, because display is the default action on any expression for which no action is specified explicitly (e.g. assignment, function parameter).
 +
 +
Another example of this theme: Exponentiation in APL is of the form 2⋆3 raising 2 to the power 3. But if no base is specified, as in ⋆3, then one would have a syntax error in its equivalent form in most other programming languages. APL however assumes the missing base to be the natural logarithm constant [[e (mathematical constant)|e]] (2.71828....), so interpreting ⋆3 as 2.71828⋆3.
 +
 +
This following immediate-mode expression generates a typical set of Pick 6 [[lottery]] numbers: six [[pseudo-random]] [[integer]]s ranging from 1 to 40, ''guaranteed non-repeating'', and displays them sorted in ascending order:
 +
 +
<pre>
 +
x[⍋x←6?40]
 +
</pre>
 +
 +
This combines the following APL functions:
 +
* The first to be executed (APL executes from right to left) is the dyadic function "?" (named "Deal" when dyadic) that returns a [[array data structure|vector]] consisting of a select number (left argument: 6 in this case) of random integers ranging from 1 to a specified maximum (right argument: 40 in this case), which, if said maximum ≥ vector length, is guaranteed to be non-repeating.
 +
* This vector is then assigned to the variable x, because it is needed later.
 +
* This vector is then sorted in ascending order by the monadic "⍋" function, which has as its right argument everything to the right of it up to the next unbalanced close-bracket or close-parenthesis. The result of ⍋ is the indices that will put its argument into ascending order.
 +
* Then the output of ⍋ is applied to the variable x, which we saved earlier, and it puts the items of x into ascending sequence.
 +
 +
Since there is no function to the left of the left-most x to tell APL what to do with the result, it simply outputs it to the display (on a single line, separated by spaces) without needing any explicit instruction to do that.
 +
 +
"?" also has a monadic equivalent called "Roll", which simply returns a single random integer between 1 and its sole operand [to the right of it], inclusive. Thus, a [[role-playing game]] program might use the expression "?20" to roll a twenty-sided die.
 +
 +
The following expression finds all [[prime number]]s from 1 to R. In both time and space, the calculation complexity is <math>O(R^2)\,\!</math> (in [[Big O notation]]).
 +
 +
<pre>
 +
(~R∊R∘.×R)/R←1↓ιR
 +
</pre>
 +
 +
Executed from right to left, this means:
 +
* <code>ιR</code> creates a vector containing [[integer]]s from <code>1</code> to <code>R</code> (if <code>R = 6</code> at the beginning of the program, <code>ιR</code> is <code>1 2 3 4 5 6</code>)
 +
* Drop first element of this vector (<code>↓</code> function), i.e. <code>1</code>. So <code>1↓ιR</code> is <code>2 3 4 5 6</code>
 +
* Set <code>R</code> to the new vector (<code>←</code>, assignment primitive), i.e. <code>2 3 4 5 6</code>
 +
* The <code>/</code> compress function is dyadic (binary) and the interpreter first evaluates its left argument:
 +
* Generate [[outer product]] of <code>R</code> multiplied by <code>R</code>, i.e. a matrix that is the ''[[multiplication table]]'' of R by R (<code>°.×</code> function), i.e.
 +
 +
{| class="wikitable"
 +
|-
 +
| 4
 +
| 6
 +
| 8
 +
| 10
 +
| 12
 +
|-
 +
| 6
 +
| 9
 +
| 12
 +
| 15
 +
| 18
 +
|-
 +
| 8
 +
| 12
 +
| 16
 +
| 20
 +
| 24
 +
|-
 +
| 10
 +
| 15
 +
| 20
 +
| 25
 +
| 30
 +
|-
 +
| 12
 +
| 18
 +
| 24
 +
| 30
 +
| 36
 +
|}
 +
* Build a vector the same length as <code>R</code> with <code>1</code> in each place where the corresponding number in <code>R</code> is in the outer product matrix (<code>∈</code>, set inclusion function), i.e. <code>0 0 1 0 1</code>
 +
* Logically negate (not) the values in the vector (change zeros to ones and ones to zeros) (<code>∼</code>, logical not function), i.e. <code>1 1 0 1 0</code>
 +
* Select the items in <code>R</code> for which the corresponding element is <code>1</code> (<code>/</code> compress function), i.e. <code>2 3 5</code>
 +
(Note, this assumes the APL origin is 1, i.e., indices start with 1. APL can be set to use 0 as the origin, which is convenient for some calculations.)
 +
 +
The following expression [[sorting|sorts]] a word list stored in matrix X according to word length:
 +
 +
<pre>
 +
X[⍋X+.≠' ';]
 +
</pre>
 +
 +
The following function "life", written in Dyalog APL, takes a boolean matrix and calculates the new generation according to [[Conway's Game of Life]]. It demonstrates the power of APL to implement a complex algorithm in very little code, but it is also very hard to follow unless one has an advanced knowledge of APL.
 +
 +
<pre>
 +
life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}
 +
</pre>
 +
 +
In the following example, also Dyalog, the first line assigns some HTML code to a variable <code>txt</code> and then uses an APL expression to remove all the HTML tags, returning the text only as shown in the last line.
 +
 +
txt←'{{code|lang=html4strict|<html><body><p>This is ''emphasized'' text</p></body></html>}}'
 +
⎕←{⍵/⍨~{⍵∨≠\⍵}⍵∊'<>'}txt
 +
{{color|#666666|This is emphasized text}}.
 +
 +
== Character set ==
 +
{{unreferenced section|date=December 2012}}
 +
{{Main|APL (codepage)}}
 +
 +
APL has always been criticized for its choice of a unique, non-standard character set. Some who learn it become ardent adherents, suggesting that there is some weight behind Iverson's idea that the notation used does make a difference. In the beginning, there were few terminal devices that could reproduce the APL character set—the most popular ones employing the [[IBM Selectric]] print mechanism along with a special APL type element. Over time, with the universal use of high-quality graphic display, printing devices and [[Unicode]] support, the APL character font problem has largely been eliminated; however, the problem of entering APL characters requires the use of [[input method editor]]s or special keyboard mappings, which may frustrate beginners accustomed to other programming languages.
 +
 +
== Use ==
 +
APL has long had a small and fervent user base. It was and still is popular in financial and insurance applications, in simulations, and in mathematical applications. APL has been used in a wide variety of contexts and for many and varied purposes. A newsletter titled "Quote-Quad" dedicated to APL has been published since the 1970s by the SIGAPL section of the Association for Computing Machinery (Quote-Quad is the name of the APL character used for text input and output).<ref>[http://www.sigapl.org/qq.htm Quote-Quad newsletter]{{dead link|date=June 2013}}</ref>
 +
 +
Before the advent of full-screen systems and until as late as the mid-1980s, systems were written such that the user entered instructions in his own business specific vocabulary. APL [[time-sharing]] vendors delivered applications in this form. On the [[I. P. Sharp Associates|I. P. Sharp]] timesharing system, a workspace called 39 MAGIC offered access to financial and airline data plus sophisticated (for the time) graphing and reporting. Another example is the GRAPHPAK workspace supplied with IBM's APL2.
 +
 +
Because of its matrix operations, APL was for some time quite popular for computer graphics programming, where graphic transformations could be encoded as matrix multiplications. One of the first commercial computer graphics houses, [[Digital Effects (studio)|Digital Effects]], based in New York City, produced an APL graphics product known as "Visions", which was used to create television commercials and, reportedly, animation for the 1982 film ''[[Tron]]''. Digital Effects' use of APL was informally described at a number of SIGAPL conferences in the late 1980s; examples discussed included the early UK [[Channel 4]] TV logo/ident. What is not clear is the extent to which APL was directly involved in the making of ''Tron'', and at this point in time the reference is more of an urban legend or historic curio than much else.{{synthesis-inline|date=December 2012}}
 +
 +
Interest in APL has steadily declined since the mid-1980s. This was partially due to the lack of a smooth migration path from higher performing mainframe implementations to low-cost personal computer alternatives, as APL implementations for computers before the [[Intel 80386]] released in the late 1980s were only suitable for small applications. The growth of end-user computing tools such as [[Microsoft Excel]] and [[Microsoft Access]] also eroded into potential APL usage. These are appropriate platforms for what may have been mainframe APL applications in the 1970s and 1980s. Some APL users migrated to the [[J programming language]], which offers more advanced features. Lastly, the decline was also due in part to the growth of [[MATLAB]], [[GNU Octave]], and [[Scilab]]. These scientific computing array-oriented platforms provide an interactive computing experience similar to APL, but more resemble conventional programming languages such as Fortran, and use standard ASCII.
 +
 +
Notwithstanding this decline, APL finds continued use in certain fields, such as accounting research.<ref>{{cite web | url=http://www.gsb.stanford.edu/programs/phd/academic-experience/fields/accounting/requirements | title=Stanford Accounting PhD requirements | publisher=Gsb.stanford.edu | accessdate=2014-01-09}}</ref>
 +
 +
== Standardization ==
 +
APL has been standardized by the [[American National Standards Institute|ANSI]] [[working group]] X3J10 and [[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]] Joint Technical Committee 1 Subcommittee 22 Working Group 3. The Core APL language is specified in ISO 8485:1989, and the Extended APL language is specified in ISO/IEC 13751:2001.
 +
 +
== See also ==
 +
* [[A+ (programming language)]]
 +
* [[APL Shared Variables]]
 +
* [[I. P. Sharp Associates]]
 +
* [[IBM Type-III Library]]
 +
* [[IBM 1130]]
 +
* [[Iverson Award]]
 +
* [[J (programming language)]]
 +
* [[LYaPAS]]
 +
* [[Scientific Time Sharing Corporation]]
 +
* [[Soliton Incorporated]]
 +
 +
== References ==
 +
{{reflist | 30em}}
 +
 +
== Further reading ==
 +
* [http://www.slac.stanford.edu/pubs/slacreports/slac-r-114.html ''An APL Machine''] (1970 Stanford doctoral dissertation by Philip Abrams)
 +
* [http://sigapl.org/Articles/MichaelMontalbanoPersonalViewOfAPL.php ''A Personal History Of APL''] (1982 article by [[Michael S. Montalbano]])
 +
* {{cite journal | url=http://www.research.ibm.com/journal/sj/304/ibmsj3004N.pdf | title=Language as an intellectual tool: From hieroglyphics to APL | year=1991 | first=Donald B. | last=McIntyre | journal=IBM Systems Journal | volume=30 | issue=4 | archiveurl=http://web.archive.org/web/20060504050437/http://www.research.ibm.com/journal/sj/304/ibmsj3004N.pdf | archivedate=May 4, 2006}}
 +
* {{cite journal | url=http://www.research.ibm.com/journal/sj/304/ibmsj3004O.pdf | title=A Personal view of APL | year=1991 | first=Kenneth E. | last=Iverson | authorlink=Kenneth E. Iverson | journal=IBM Systems Journal | volume=30 | issue=4 | archiveurl=http://web.archive.org/web/20080227012149/http://www.research.ibm.com/journal/sj/304/ibmsj3004O.pdf | archivedate=February 27, 2008}}
 +
* [http://www.softwarepreservation.org/projects/apl/Physics%20in%20APL2/APROGRAMMING%20LANGUAGE/view ''A Programming Language''] by [[Kenneth E. Iverson]]
 +
* [http://www.softwarepreservation.org/projects/apl/paper/197201_APL%20In%20Exposition_320-3010.pdf/view ''APL in Exposition''] by [[Kenneth E. Iverson]]
 +
* Brooks, Frederick P.; Kenneth Iverson (1965). ''Automatic Data Processing, System/360 Edition''. ISBN 0-471-10605-4.
 +
* {{cite book | last=Askoolum | first=Ajay | title=System Building with APL + Win | date = August 2006 | publisher=Wiley | isbn=978-0-470-03020-2}}
 +
* {{cite journal | url=http://www.research.ibm.com/journal/sj/032/falkoff.pdf | title=A Formal Description of SYSTEM/360 | first1=Adin D. | last1=Falkoff | first2=Kenneth E. | last2=Iverson | authorlink2=Kenneth E. Iverson | first3=Edward H. | last3=Sussenguth | authorlink3=  Edward H. Sussenguth | journal=IBM Systems Journal | volume=3 | issue=3 | location=New York | year=1964 | archiveurl=http://web.archive.org/web/20080227012111/http://www.research.ibm.com/journal/sj/032/falkoff.pdf | archivedate=February 27, 2008}}
 +
* ''History of Programming Languages'', chapter 14{{Clarify|date=June 2010}}
 +
* {{cite book | last=Banon | first=Gerald Jean Francis | title=Bases da Computacao Grafica | publisher=Campus | location=Rio de Janeiro | year=1989 | page=141}}
 +
* {{cite book | last=LePage | first=Wilbur R. | title=Applied A.P.L. Programming | publisher=Prentice Hall | year=1978}}
 +
 +
== External links ==
 +
{{Commons category}}
 +
* {{dmoz|Computers/Programming/Languages/APL|APL}}
 +
* [news://comp.lang.apl comp.lang.apl] [[newsgroup]] ([http://groups.google.com/group/comp.lang.apl/topics Google Groups archive])
 +
* [http://aplwiki.com/ APL Wiki]
 +
* [http://www.sigapl.org/ SIGAPL]
 +
* [http://www.fscript.org/documentation/OOPAL.pdf OOPAL: Integrating Array Programming in Object-Oriented Programming]
 +
* [http://web.archive.org/web/20080228023208/http://www.dyalog.dk/whatsnew/OO4APLERS.pdf An introduction to Object Oriented APL]
 +
* [http://www.espenhaug.com/black_scholes.html Comparison of Black-Scholes options pricing model in many languages, including APL]
 +
* [http://sourceforge.net/projects/openapl/ OpenAPL project page on Source Forge]
 +
* [http://home.earthlink.net/~swsirlin/aplcc.html The APL c compiler project (Tim Budd et al.)]
 +
* [http://www.apl2c.de/home/Links/links.html APL2C], a source of links to APL compilers
 +
* [http://www.microapl.com/apl/APL1_2.PDF A Practical Introduction to APL1 & APL2]
 +
* [http://www.computerhistory.org/atchm/computer-history-museum-software-license-agreement/ License Agreement], IBM APL\360 source code for non-commercial use
 +
 +
[[Category:Array programming languages]]
 +
[[Category:Functional languages]]
 +
[[Category:Dynamic programming languages]]
 +
[[Category:APL programming language family]]
 +
[[Category:.NET programming languages]]
 +
[[Category:IBM software]]
 +
[[Category:Command shells]] <!-- [[IBM 5100]] as per the toggle switch on the front panel -->
 +
[[Category:Programming languages created in 1964]]

Revision as of 13:43, 31 July 2014

Template:Redirects here Template:Infobox programming language Template:APLcode

File:I like APL graphic.jpg
Promotional material for APL from 1976

APL (named after the book A Programming Language)[1] is a programming language developed in the 1960s by Kenneth E. Iverson. It was an important influence on the development of spreadsheets, functional programming,[2] and computer math packages.[3] It has also inspired several other programming languages.[4][5][6] It is still used today for certain applications.[7][8]

History

The first incarnation of what was later to be the APL programming language was published and formalized in A Programming Language,[1] a book describing a notation invented in 1957 by Kenneth E. Iverson while at Harvard University. Iverson had developed a mathematical notation for manipulating arrays that he taught to his students.

Iverson described the premise of the book in the Preface: "Applied mathematics is largely concerned with the design and analysis of explicit procedures for calculating the exact or approximate values of various functions. Such explicit procedures are called algorithms or programs. Because an effective notation for the description of programs exhibits considerable syntactic structure, it is called a programming language."

In 1960, he began work for IBM and, working with Adin Falkoff, created APL based on the notation he had developed. This notation was used inside IBM for short research reports on computer systems, such as the Burroughs B5000 and its stack mechanism when stack machines versus register machines were being evaluated by IBM for upcoming computers.

Also in 1960, Iverson was already using his notation in a draft copy of Chapter 6 called "A programming language" for the book he was writing with Fred Brooks, Automatic Data Processing, which would later be published in 1963.[9][10]

Published in 1962, the notation described in A Programming Language[1] was recognizable yet distinct from later APL.

As early as 1962, the first attempt to use the notation to describe a complete computer system happened after Falkoff discussed with Dr. William C. Carter his work in the standardization of the instruction set for the machines that later became the IBM System/360 family.

In 1963, Dr. Herbert Hellerman, working at the IBM Systems Research Institute, implemented a part of the notation on an IBM 1620 computer, and it was used by students in a special high school course on calculating transcendental functions by series summation. Students tested their code in Dr. Hellerman's lab. This implementation of a portion of the notation was called PAT (Personalized Array Translator).[11]

In 1963, Falkoff, Iverson, and Edward H. Sussenguth Jr., all working at IBM, used the notation for a formal description of the IBM System/360 series machine architecture and functionality, which resulted in a paper published in IBM Systems Journal in 1964. After this was published, the team turned their attention to an implementation of the notation on a computer system. One of the motivations for this focus of implementation was the interest of John L. Lawrence who had new duties with Science Research Associates, an educational company bought by IBM in 1964. Lawrence asked Iverson and his group to help utilize the language as a tool for the development and use of computers in education.[12]

After Lawrence M. Breed and Philip S. Abrams of Stanford University joined the team at IBM Research, they continued their prior work on an implementation programmed in FORTRAN IV for a portion of the notation was done for the IBM 7090 computer running under the IBSYS operating system. This work was finished in late 1965 and later known as IVSYS (Iverson System). The basis of this implementation was described in detail by Abrams in a Stanford University Technical Report, "An Interpreter for Iverson Notation" in 1966.[13] Like Hellerman's PAT system earlier, this implementation did not include the APL character set but used special English reserved words for functions and operators. The system was later adapted for a time-sharing system and, by November 1966, it had been reprogrammed for the IBM/360 Model 50 computer running in a time sharing mode and was used internally at IBM.[14]

IBM typeballs (one OCR) with clip, Template:€ coin for scale

A key development in the ability to use APL effectively, before the widespread use of CRT terminals, was the development of a special IBM Selectric typewriter interchangeable typeball with all the special APL characters on it. This was used on paper printing terminal workstations using the Selectric typewriter and typeball mechanism, such as the IBM 1050 and IBM 2741 terminal. Keycaps could be placed over the normal keys to show which APL characters would be entered and typed when that key was struck. For the first time, a programmer could actually type in and see real APL characters as used in Iverson's notation and not be forced to use awkward English keyword representations of them. Falkoff and Iverson had the special APL Selectric typeballs, 987 and 988, designed in late 1964, although no APL computer system was available to use them.[15] Iverson cited Falkoff as the inspiration for the idea of using an IBM Selectric typeball for the APL character set.[16]

A programmer's view of the IBM 2741 keyboard layout with the APL typeball print head inserted

Some APL symbols, even with the APL characters on the typeball, still had to be typed in by over-striking two existing typeball characters. An example would be the "grade up" character, which had to be made from a "delta" (shift-H) and a "Sheffer stroke" (shift-M). This was necessary because the APL character set was larger than the 88 characters allowed on the Selectric typeball.

The first APL interactive login and creation of an APL workspace was in 1966 by Larry Breed using an IBM 1050 terminal at the IBM Mohansic Labs near Thomas J. Watson Research Center, the home of APL, in Yorktown Heights, New York.[15]

IBM was chiefly responsible for the introduction of APL to the marketplace. APL was first available in 1967 for the IBM 1130 as APL\1130.[17][18] It would run in as little as 8k 16-bit words of memory, and used a dedicated 1 megabyte hard disk.

APL gained its foothold on mainframe timesharing systems from the late 1960s through the early 1980s, in part because it would run on lower-specification systems that were not equipped with Dynamic Address Translation hardware.[19] Additional improvements in performance for selected IBM System/370 mainframe systems included the "APL Assist Microcode" in which some support for APL execution was included in the actual firmware as opposed to APL being exclusively a software product. Somewhat later, as suitably performing hardware was finally becoming available in the mid- to late-1980s, many users migrated their applications to the personal computer environment.

Early IBM APL interpreters for IBM 360 and IBM 370 hardware implemented their own multi-user management instead of relying on the host services, thus they were timesharing systems in their own right. First introduced in 1966, the APL\360[20][21][22] system was a multi-user interpreter. The ability to programmatically communicate with the operating system for information and setting interpreter system variables was done through special privileged "I-beam" functions, using both monadic and dyadic operations.[23]

In 1973, IBM released APL.SV, which was a continuation of the same product, but which offered shared variables as a means to access facilities outside of the APL system, such as operating system files. In the mid-1970s, the IBM mainframe interpreter was even adapted for use on the IBM 5100 desktop computer, which had a small CRT and an APL keyboard, when most other small computers of the time only offered BASIC. In the 1980s, the VSAPL program product enjoyed widespread usage with CMS, TSO, VSPC, MUSIC/SP and CICS users.

In 1973-1974, Dr. Patrick E. Hagerty directed the implementation of the University of Maryland APL interpreter for the Sperry Univac 1100 Series mainframe computers.[24] At the time, Sperry had nothing. In 1974, student Alan Stebbens was assigned the task of implementing an internal function.[25]

Several timesharing firms sprang up in the 1960s and 1970s that sold APL services using modified versions of the IBM APL\360[22] interpreter. In North America, the better-known ones were I. P. Sharp Associates, STSC, and The Computer Company (TCC). With the advent first of less expensive mainframes such as the IBM 4300 and later the personal computer, the timesharing industry had all but disappeared by the mid-1980s.

Sharp APL was available from I. P. Sharp Associates, first on a timesharing basis in the 1960s, and later as a program product starting around 1979. Sharp APL was an advanced APL implementation with many language extensions, such as packages (the ability to put one or more objects into a single variable), file system, nested arrays, and shared variables.

APL interpreters were available from other mainframe and mini-computer manufacturers as well, notably Burroughs, CDC, Data General, DEC, Harris, Hewlett-Packard, Siemens AG, Xerox, and others.

Garth Foster of Syracuse University sponsored regular meetings of the APL implementers' community at Syracuse's Minnowbrook Conference Center in rural upstate New York. In later years, Eugene McDonnell organized similar meetings at the Asilomar Conference Grounds near Monterey, California, and at Pajaro Dunes near Watsonville, California. The SIGAPL special interest group of the Association for Computing Machinery continues to support the APL community.[26]

In 1979, Iverson received the Turing Award for his work on APL.[27]

APL2

Starting in the early 1980s, IBM APL development, under the leadership of Dr Jim Brown, implemented a new version of the APL language that contained as its primary enhancement the concept of nested arrays, where an array can contain other arrays, as well as new language features which facilitated the integration of nested arrays into program workflow. Ken Iverson, no longer in control of the development of the APL language, left IBM and joined I. P. Sharp Associates, where one of his major contributions was directing the evolution of Sharp APL to be more in accordance with his vision.{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

As other vendors were busy developing APL interpreters for new hardware, notably Unix-based microcomputers, APL2 was almost always the standard chosen for new APL interpreter developments. Even today, most APL vendors cite APL2 compatibility, which only approaches 100%, as a selling point for their products.{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

APL2 for IBM mainframe computers is still available as of 2013-07-29,[28] and was first available for CMS and TSO in 1984.[29] The APL2 Workstation edition (Windows, OS/2, AIX, Linux, and Solaris) followed much later in the early 1990s.{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

Microcomputers

The first microcomputer implementation of APL was on the Intel 8008-based MCM/70, the first general purpose personal computer, in 1973.

IBM's own IBM 5100 microcomputer (1975) offered APL as one of two built-in ROM-based interpreted languages for the computer, complete with a keyboard and display that supported all the special symbols used in the language.

In 1976 DNA Systems introduced an APL interpreter for their TSO Operating System, which ran timesharing on the IBM 1130, Digital Scientific Meta-4, General Automation GA 18/30 and Computer Hardware CHI 21/30.

The VideoBrain Family Computer, released in 1977, only had one programming language available for it, and that was a dialect of APL called APL/S.[30]

A Small APL for the Intel 8080 called EMPL was released in 1977, and Softronics APL, with most of the functions of full APL, for 8080-based CP/M systems was released in 1979.

In 1977, the Canadian firm Telecompute Integrated Systems, Inc. released a business-oriented APL interpreter known as TIS APL, for Z80-based systems. It featured the full set of file functions for APL, plus a full screen input and switching of right and left arguments for most dyadic operators by introducing the ~. prefix to all single character dyadic functions such as - or /.

Vanguard APL was available for Z80 CP/M-based processors in the late 1970s. TCC released APL.68000 in the early 1980s for Motorola 68000-based processors, this system being the basis for MicroAPL Limited's APLX product. I. P. Sharp Associates released a version of their APL interpreter for the IBM PC and PC/370.[31] For the IBM PC, an emulator was written that facilitated reusing much of the IBM 370 mainframe code. Arguably, the best known APL interpreter for the IBM Personal Computer was STSC's APL*Plus/PC.{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

The Commodore SuperPET, introduced in 1981, included an APL interpreter developed by the University of Waterloo.

In the early 1980s, the Analogic Corporation developed The APL Machine, which was an array processing computer designed to be programmed only in APL. There were actually three processing units, the user's workstation, an IBM PC, where programs were entered and edited, a Motorola 68000 processor that ran the APL interpreter, and the Analogic array processor that executed the primitives.[32] At the time of its introduction, The APL Machine was likely the fastest APL system available. Although a technological success, The APL Machine was a marketing failure. The initial version supported a single process at a time. At the time the project was discontinued, the design had been completed to allow multiple users. As an aside, an unusual aspect of The APL Machine was that the library of workspaces was organized such that a single function or variable that was shared by many workspaces existed only once in the library. Several of the members of The APL Machine project had previously spent a number of years with Burroughs implementing APL\700.

At one stage, it was claimed by Bill Gates in his Open Letter to Hobbyists, Microsoft Corporation planned to release a version of APL, but these plans never materialized.

An early 1978 publication of Rodnay Zaks from Sybex was A microprogrammed APL implementation ISBN 0-89588-005-9, which is the complete source listing for the microcode for a Digital Scientific Corporation Meta 4 microprogrammable processor implementing APL. This topic was also the subject of his PhD thesis.[33][34]

In 1979, William Yerazunis wrote a partial version of APL in Prime Computer FORTRAN, extended it with graphics primitives, and released it. This was also the subject of his Masters thesis.[35]

Extensions

Recent extensions to APL include:

Design

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }} {{ safesubst:#invoke:Unsubst||$N=Tone |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }}

Unlike traditionally structured programming languages, code in APL is typically structured as chains of monadic or dyadic functions and operators acting on arrays. As APL has many nonstandard primitives (functions and operators, indicated by a single symbol or a combination of a few symbols), it does not have function or operator precedence. Early APL implementations did not have control structures (do or while loops, if-then-else), but by using array operations, use of structured programming constructs was not necessary, as an operation was carried out on all the elements of the array in a single statement. For example, the iota (ι) function (ιN yields a one-dimensional array, or vector, 1 2 3 ... N) can replace for-loop iteration. More recent implementations of APL generally include comprehensive control structures, so that data structure and program control flow can be clearly and cleanly separated.

The APL environment is called a workspace. In a workspace the user can define programs and data, i.e. the data values exist also outside the programs, and the user can manipulate the data without the necessity to define a program. For example,

N ← 4 5 6 7

assigns the vector value 4 5 6 7 to N;

N+4

adds 4 to all elements of the vector (giving 8 9 10 11) and prints them (a return value not assigned at the end of a statement to a variable using the assignment arrow is displayed by the APL interpreter);

+/N

prints the sum of N, i.e. 22.

These operations can then be combined in a single statement, e.g.

m ← +/ιn

assigns to m the scalar value n(n+1)/2, i.e. .

The user can save the workspace with all values, programs and execution status.

APL is well known for its use of a set of non-ASCII symbols, which are an extension of traditional arithmetic and algebraic notation. Having single character names for SIMD vector functions is one way that APL enables compact formulation of algorithms for data transformation such as computing Conway's Game of Life in one line of code.[42] In nearly all versions of APL, it is theoretically possible to express any computable function in one expression, that is, in one line of code.{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

Because of the unusual character set, many programmers use special keyboards with APL keytops for authoring APL code. Although there are various ways to write APL code using only ASCII characters,[43] in practice, it is almost never done. (This may be thought to support Iverson's thesis about notation as a tool of thought.)[44] Most if not all modern implementations use standard keyboard layouts, with special mappings or input method editors to access non-ASCII characters. Historically, the APL font has been distinctive, with uppercase italic alphabetic characters and upright numerals and symbols. Most vendors continue to display the APL character set in a custom font.

Advocates of APLTemplate:Who claim that the examples of so-called write-only code are almost invariably examples of poor programming practice or novice mistakes, which can occur in any language. Advocates of APL also claim that they are far more productive with APL than with more conventional computer languages, and that working software can be implemented in far less time and with far fewer programmers than using other technology. APL lets an individual solve harder problems faster. Also, being compact and terse, APL lends itself well to larger scale software development as complexity arising from a large number of lines of code can be dramatically reduced. Many APL advocates and practitioners view programming in standard programming languages, such as COBOL and Java, as comparatively tedious. APL is often found where time-to-market is important, such as with trading systems. {{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }}

Iverson later designed the J programming language, which uses ASCII with digraphs instead of special symbols.

Execution

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }}

Interpreters

APLNext (formerly APL2000) offers an advanced APL interpreter that operates under Linux, Unix, and Windows. It supports Windows automation, supports calls to operating system and user defined DLLs, has an advanced APL File System, and represents the current level of APL language development. APL2000's product is an advanced continuation of STSC's successful APL*Plus/PC and APL*Plus/386 product line.

Dyalog APL is an advanced APL interpreter that operates under Linux, Unix, and Windows. Dyalog has innovative extensions to the APL language, which include new object-oriented features, numerous language enhancements, plus a consistent namespace model used for both its Microsoft Automation interface, as well as native namespaces. For the Windows platform, Dyalog APL offers tight integration with .NET, plus limited integration with the Microsoft Visual Studio development platform.

IBM offers a version of IBM APL2 for IBM AIX, Linux, Sun Solaris and Windows systems. This product is a continuation of APL2 offered for IBM mainframes. IBM APL2 was arguably the most influential APL system, which provided a solid implementation standard for the next set of extensions to the language, focusing on nested arrays.

NARS2000 is an open source APL interpreter written by Bob Smith, a well-known APL developer and implementor from STSC in the 1970s and 1980s. NARS2000 contains advanced features and new datatypes, runs natively under Windows (32- and 64-bit versions), and runs under Linux and Apple Mac OS with Wine.

MicroAPL Limited offers APLX, a full-featured 64 bit interpreter for Linux, Microsoft Windows, and Mac OS systems. The core language is closely modelled on IBM's APL2 with various enhancements. APLX includes close integration with .NET, Java, Ruby and R.

Soliton Incorporated offers the SAX interpreter (Sharp APL for Unix) for Unix and Linux systems, which is a further development of I. P. Sharp Associates' Sharp APL product. Unlike most other APL interpreters, Kenneth E. Iverson had some influence in the way nested arrays were implemented in Sharp APL and SAX. Nearly all other APL implementations followed the course set by IBM with APL2, thus some important details in Sharp APL differ from other implementations.

OpenAPL is an open source implementation of APL published by Branko Bratkovic, based on code by Ken Thompson of Bell Laboratories, together with contributions by others. It is licensed under the GNU General Public License, and runs on Unix systems including Linux on x86, SPARC and other CPUs.

GNU APL is a free implementation of ISO Standard 13751 and hence similar to APL2. It runs on GNU/Linux and on Windows using Cygwin. It uses Unicode internally. GNU APL was written by Jürgen Sauermann.

Compilers

APL programs are normally interpreted and less often compiled. In reality, most APL compilers translated source APL to a lower level language such as C, leaving the machine-specific details to the lower level compiler. Compilation of APL programs was a frequently discussed topic in conferences. Although some of the newer enhancements to the APL language such as nested arrays have rendered the language increasingly difficult to compile, the idea of APL compilation is still under development today.

In the past, APL compilation was regarded as a means to achieve execution speed comparable to other mainstream languages, especially on mainframe computers. Several APL compilers achieved some levels of success, though comparatively little of the development effort spent on APL over the years went to perfecting compilation into machine code.

As is the case when moving APL programs from one vendor's APL interpreter to another, APL programs invariably will require changes to their content. Depending on the compiler, variable declarations might be needed, certain language features would need to be removed or avoided, or the APL programs would need to be cleaned up in some way. Some features of the language, such as the execute function (an expression evaluator) and the various reflection and introspection functions from APL, such as the ability to return a function's text or to materialize a new function from text, are simply not practical to implement in machine code compilation.

A commercial compiler was brought to market by STSC in the mid-1980s as an add-on to IBM's VSAPL Program Product. Unlike more modern APL compilers, this product produced machine code that would execute only in the interpreter environment, it was not possible to eliminate the interpreter component. The compiler could compile many scalar and vector operations to machine code, but it would rely on the APL interpreter's services to perform some more advanced functions, rather than attempt to compile them. However, dramatic speedups did occur, especially for heavily iterative APL code.

Around the same time, the book An APL Compiler by Timothy Budd appeared in print. This book detailed the construction of an APL translator, written in C, which performed certain optimizations such as loop fusion specific to the needs of an array language. The source language was APL-like in that a few rules of the APL language were changed or relaxed to permit more efficient compilation. The translator would emit C code which could then be compiled and run well outside of the APL workspace.

Today, execution speed is less critical and many popular languages are implemented using virtual machines: instructions that are interpreted at runtime. The Burroughs/Unisys APLB interpreter (1982) was the first to use dynamic incremental compilation to produce code for an APL-specific virtual machine. It recompiled on-the-fly as identifiers changed their functional meanings. In addition to removing parsing and some error checking from the main execution path, such compilation also streamlines the repeated entry and exit of user-defined functional operands. This avoids the stack setup and take-down for function calls made by APL's built-in operators such as Reduce and Each.

APEX, a research APL compiler, is available from Snake Island Research Inc. APEX compiles flat APL (a subset of ISO N8485) into SAC, a functional array language with parallel semantics, and currently runs under Linux. APEX-generated code uses loop fusion and array contraction, special-case algorithms not generally available to interpreters (e.g., upgrade of permutation vector), to achieve a level of performance comparable to that of Fortran.

The APLNext VisualAPL system is a departure from a conventional APL system in that VisualAPL is a true .NET language which is fully interoperable with other .NET languages such as VB.NET and C#. VisualAPL is inherently object oriented and Unicode-based. While VisualAPL incorporates most of the features of standard APL implementations, the VisualAPL language extends standard APL to be .NET-compliant. VisualAPL is hosted in the standard Microsoft Visual Studio IDE and as such, invokes compilation in a manner identical to that of other .NET languages. By producing Common Intermediate Language (CIL) code, it utilizes the Microsoft just-in-time compiler (JIT) to support 32-bit or 64-bit hardware. Substantial performance speed-ups over standard APL have been reported,{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }} especially when (optional) strong typing of function arguments is used.

An APL to C# translator is available from Causeway Graphical Systems. This product was designed to allow the APL code, translated to equivalent C#, to run completely outside of the APL environment. The Causeway compiler requires a run-time library of array functions. Some speedup, sometimes dramatic, is visible, but happens on account of the optimisations inherent in Microsoft's .NET Framework.

Matrix optimizations

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }}

APL was unique in the speed with which it could perform complicated matrix operations. For example, a very large matrix multiplication would take only a few seconds on a machine that was much less powerful than those today.{{ safesubst:#invoke:Unsubst||date=__DATE__ |$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }} There were both technical and economic reasons for this advantage:

  • Commercial interpreters delivered highly tuned linear algebra library routines.
  • Very low interpretive overhead was incurred per-array—not per-element.
  • APL response time compared favorably to the runtimes of early optimizing compilers.
  • IBM provided microcode assist for APL on a number of IBM/370 mainframes.

Phil Abrams' much-cited paper "An APL Machine" illustrated how APL could make effective use of lazy evaluation where calculations would not actually be performed until the results were needed and then only those calculations strictly required. An obvious (and easy to implement) lazy evaluation is the J-vector: when a monadic iota is encountered in the code, it is kept as a representation instead of being expanded in memory; in future operations, a J-vector's contents are the loop's induction register, not reads from memory.

Although such techniques were not widely used by commercial interpreters, they exemplify the language's best survival mechanism: not specifying the order of scalar operations or the exact contents of memory. As standardized, in 1983 by ANSI working group X3J10, APL remains highly data-parallel. This gives language implementers immense freedom to schedule operations as efficiently as possible. As computer innovations such as cache memory, and SIMD execution became commercially available, APL programs are ported with almost no extra effort spent re-optimizing low-level details.

Terminology

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }}

APL makes a clear distinction between functions and operators. Functions take arrays (variables or constants or expressions) as arguments, and return arrays as results. Operators (similar to higher-order functions) take functions or arrays as arguments, and derive related functions. For example the "sum" function is derived by applying the "reduction" operator to the "addition" function. Applying the same reduction operator to the "maximum" function (which returns the larger of two numbers) derives a function which returns the largest of a group (vector) of numbers. In the J language, Iverson substituted the terms "verb" for "function" and "adverb" or "conjunction" for "operator".

APL also identifies those features built into the language, and represented by a symbol, or a fixed combination of symbols, as primitives. Most primitives are either functions or operators. Coding APL is largely a process of writing non-primitive functions and (in some versions of APL) operators. However a few primitives are considered to be neither functions nor operators, most noticeably assignment.

Some words used in APL literature have meanings that differ from those in both mathematics and the generality of computer science.

Term Description
function operation or mapping that takes zero, one (right) or two (left & right) array valued arguments and may return an array valued result. A function may be:
  • Primitive: built-in and represented by a single glyph;[45]
  • Defined: as a named and ordered collection of program statements;[45]
  • Derived: as a combination of an operator with its arguments.[45]
array data valued object of zero or more orthogonal dimensions in row-major order in which each item is a primitive scalar datum or another array.[46]
niladic not taking or requiring any arguments,[47]
monadic requiring only one argument; on the right for a function, on the left for an operator, unary[47]
dyadic requiring both a left and a right argument, binary[47]
ambivalent or nomadic capable of use in a monadic or dyadic context, permitting its left argument to be elided[45]
operator operation or mapping that takes one (left) or two (left & right) function or array valued arguments (operands) and derives a function. An operator may be:
  • Primitive: built-in and represented by a single glyph;[45]
  • Defined: as a named and ordered collection of program statements.[45]

Syntax

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }}

{{#invoke:main|main}}

Examples

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }}

This displays "Hello, world":

'Hello, world'

A design theme in APL is to define default actions in some cases that would be syntax errors in their equivalent forms in most other programming languages. APL is economical in its character usage.

The 'Hello, world' string constant above displays, because display is the default action on any expression for which no action is specified explicitly (e.g. assignment, function parameter).

Another example of this theme: Exponentiation in APL is of the form 2⋆3 raising 2 to the power 3. But if no base is specified, as in ⋆3, then one would have a syntax error in its equivalent form in most other programming languages. APL however assumes the missing base to be the natural logarithm constant e (2.71828....), so interpreting ⋆3 as 2.71828⋆3.

This following immediate-mode expression generates a typical set of Pick 6 lottery numbers: six pseudo-random integers ranging from 1 to 40, guaranteed non-repeating, and displays them sorted in ascending order:

x[⍋x←6?40]

This combines the following APL functions:

  • The first to be executed (APL executes from right to left) is the dyadic function "?" (named "Deal" when dyadic) that returns a vector consisting of a select number (left argument: 6 in this case) of random integers ranging from 1 to a specified maximum (right argument: 40 in this case), which, if said maximum ≥ vector length, is guaranteed to be non-repeating.
  • This vector is then assigned to the variable x, because it is needed later.
  • This vector is then sorted in ascending order by the monadic "⍋" function, which has as its right argument everything to the right of it up to the next unbalanced close-bracket or close-parenthesis. The result of ⍋ is the indices that will put its argument into ascending order.
  • Then the output of ⍋ is applied to the variable x, which we saved earlier, and it puts the items of x into ascending sequence.

Since there is no function to the left of the left-most x to tell APL what to do with the result, it simply outputs it to the display (on a single line, separated by spaces) without needing any explicit instruction to do that.

"?" also has a monadic equivalent called "Roll", which simply returns a single random integer between 1 and its sole operand [to the right of it], inclusive. Thus, a role-playing game program might use the expression "?20" to roll a twenty-sided die.

The following expression finds all prime numbers from 1 to R. In both time and space, the calculation complexity is (in Big O notation).

(~R∊R∘.×R)/R←1↓ιR

Executed from right to left, this means:

  • ιR creates a vector containing integers from 1 to R (if R = 6 at the beginning of the program, ιR is 1 2 3 4 5 6)
  • Drop first element of this vector ( function), i.e. 1. So 1↓ιR is 2 3 4 5 6
  • Set R to the new vector (, assignment primitive), i.e. 2 3 4 5 6
  • The / compress function is dyadic (binary) and the interpreter first evaluates its left argument:
  • Generate outer product of R multiplied by R, i.e. a matrix that is the multiplication table of R by R (°.× function), i.e.
4 6 8 10 12
6 9 12 15 18
8 12 16 20 24
10 15 20 25 30
12 18 24 30 36
  • Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix (, set inclusion function), i.e. 0 0 1 0 1
  • Logically negate (not) the values in the vector (change zeros to ones and ones to zeros) (, logical not function), i.e. 1 1 0 1 0
  • Select the items in R for which the corresponding element is 1 (/ compress function), i.e. 2 3 5

(Note, this assumes the APL origin is 1, i.e., indices start with 1. APL can be set to use 0 as the origin, which is convenient for some calculations.)

The following expression sorts a word list stored in matrix X according to word length:

X[⍋X+.≠' ';]

The following function "life", written in Dyalog APL, takes a boolean matrix and calculates the new generation according to Conway's Game of Life. It demonstrates the power of APL to implement a complex algorithm in very little code, but it is also very hard to follow unless one has an advanced knowledge of APL.

life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

In the following example, also Dyalog, the first line assigns some HTML code to a variable txt and then uses an APL expression to remove all the HTML tags, returning the text only as shown in the last line.

txt←'<html><body><p>This is ''emphasized'' text</p></body></html>'
⎕←{⍵/⍨~{⍵∨≠\⍵}⍵∊'<>'}txt
This is emphasized text.

Character set

{{ safesubst:#invoke:Unsubst||$N=Unreferenced section |date=__DATE__ |$B= {{ safesubst:#invoke:Unsubst||$N=Unreferenced |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} }} {{#invoke:main|main}}

APL has always been criticized for its choice of a unique, non-standard character set. Some who learn it become ardent adherents, suggesting that there is some weight behind Iverson's idea that the notation used does make a difference. In the beginning, there were few terminal devices that could reproduce the APL character set—the most popular ones employing the IBM Selectric print mechanism along with a special APL type element. Over time, with the universal use of high-quality graphic display, printing devices and Unicode support, the APL character font problem has largely been eliminated; however, the problem of entering APL characters requires the use of input method editors or special keyboard mappings, which may frustrate beginners accustomed to other programming languages.

Use

APL has long had a small and fervent user base. It was and still is popular in financial and insurance applications, in simulations, and in mathematical applications. APL has been used in a wide variety of contexts and for many and varied purposes. A newsletter titled "Quote-Quad" dedicated to APL has been published since the 1970s by the SIGAPL section of the Association for Computing Machinery (Quote-Quad is the name of the APL character used for text input and output).[48]

Before the advent of full-screen systems and until as late as the mid-1980s, systems were written such that the user entered instructions in his own business specific vocabulary. APL time-sharing vendors delivered applications in this form. On the I. P. Sharp timesharing system, a workspace called 39 MAGIC offered access to financial and airline data plus sophisticated (for the time) graphing and reporting. Another example is the GRAPHPAK workspace supplied with IBM's APL2.

Because of its matrix operations, APL was for some time quite popular for computer graphics programming, where graphic transformations could be encoded as matrix multiplications. One of the first commercial computer graphics houses, Digital Effects, based in New York City, produced an APL graphics product known as "Visions", which was used to create television commercials and, reportedly, animation for the 1982 film Tron. Digital Effects' use of APL was informally described at a number of SIGAPL conferences in the late 1980s; examples discussed included the early UK Channel 4 TV logo/ident. What is not clear is the extent to which APL was directly involved in the making of Tron, and at this point in time the reference is more of an urban legend or historic curio than much else.Template:Synthesis-inline

Interest in APL has steadily declined since the mid-1980s. This was partially due to the lack of a smooth migration path from higher performing mainframe implementations to low-cost personal computer alternatives, as APL implementations for computers before the Intel 80386 released in the late 1980s were only suitable for small applications. The growth of end-user computing tools such as Microsoft Excel and Microsoft Access also eroded into potential APL usage. These are appropriate platforms for what may have been mainframe APL applications in the 1970s and 1980s. Some APL users migrated to the J programming language, which offers more advanced features. Lastly, the decline was also due in part to the growth of MATLAB, GNU Octave, and Scilab. These scientific computing array-oriented platforms provide an interactive computing experience similar to APL, but more resemble conventional programming languages such as Fortran, and use standard ASCII.

Notwithstanding this decline, APL finds continued use in certain fields, such as accounting research.[49]

Standardization

APL has been standardized by the ANSI working group X3J10 and ISO/IEC Joint Technical Committee 1 Subcommittee 22 Working Group 3. The Core APL language is specified in ISO 8485:1989, and the Extended APL language is specified in ISO/IEC 13751:2001.

See also

References

  1. 1.0 1.1 1.2 {{#invoke:citation/CS1|citation |CitationClass=book }}
  2. Template:Cite web
  3. Cite error: Invalid <ref> tag; no text was provided for refs named mworks
  4. Cite error: Invalid <ref> tag; no text was provided for refs named jinsp
  5. Cite error: Invalid <ref> tag; no text was provided for refs named kinsp
  6. Cite error: Invalid <ref> tag; no text was provided for refs named qinsp
  7. Template:Cite web
  8. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
  9. Iverson, Kenneth E., "Automatic Data Processing: Chapter 6: A programming language", 1960, DRAFT copy for Brooks and Iverson 1963 book, "Automatic Data Processing".
  10. Brooks, Fred; Iverson, Kenneth, (1963), Automatic Data Processing, John Wiley & Sons Inc.
  11. Hellerman, H., "Experimental Personalized Array Translator System", Communications of the ACM, 7, 433 (July, 1964).
  12. Falkoff, Adin D.; Iverson, Kenneth E., "The Evolution of APL", ACM SIGPLAN Notices 13, 1978-08.
  13. Abrams, Philip S., An interpreter for "Iverson notation", Technical Report: CS-TR-66-47, Department of Computer Science, Stanford University, August 1966.
  14. Haigh, Thomas, "Biographies: Kenneth E. Iverson", IEEE Annals of the History of Computing, 2005
  15. 15.0 15.1 Breed, Larry, "The First APL Terminal Session", APL Quote Quad, Association for Computing Machinery, Volume 22, Number 1, September 1991, p.2-4.
  16. Adin Falkoff - Computer History Museum. "Iverson credited him for choosing the name APL and the introduction of the IBM golf-ball typewriter with the replacement typehead, which provided the famous character set to represent programs."
  17. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
  18. APL\1130 Manual, May 1969
  19. Template:Cite web
  20. Falkoff, Adin; Iverson, Kenneth E., "APL\360 Users Guide", IBM Research, Thomas J. Watson Research Center, Yorktown Heights, NY, August 1968.
  21. "APL\360 Terminal System", IBM Research, Thomas J. Watson Research Center, March 1967.
  22. 22.0 22.1 {{#invoke:citation/CS1|citation |CitationClass=book }}
  23. Falkoff, Adin D.; Iverson, Kenneth E.,The Design of APL, IBM Journal of Research and Development, Volume 17, Number 4, July 1973. "These environmental defined functions were based on the use of still another class of functions—called "I-beams" because of the shape of the symbol used for them—which provide a more general facility for communication between APL programs and the less abstract parts of the system. The I-beam functions were first introduced by the system programmers to allow them to execute System/360 instructions from within APL programs, and thus use APL as a direct aid in their programming activity. The obvious convenience of functions of this kind, which appeared to be part of the language, led to the introduction of the monadic I-beam function for direct use by anyone. Various arguments to this function yielded information about the environment such as available space and time of day."
  24. Template:Cite web
  25. Template:Cite web
  26. Template:Cite web
  27. Template:Cite web
  28. Template:Cite web
  29. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
  30. "VideoBrain Family Computer", Popular Science, November 1978, advertisement.
  31. Higgins, Donald S., "PC/370 virtual machine", ACM SIGSMALL/PC Notes, Volume 11, Issue 3 (August 1985), pp.23 - 28, 1985.
  32. [1],Yahoo! Group APL-L, April, 2003
  33. Zaks, Rodnay, "A Microprogrammed APL Implementation,", Ph.D. Thesis, University of California, Berkeley, June 1972.
  34. Zaks, Rodnay, "Microprogrammed APL,", Fifth IEEE Computer Conference Proceedings, Sep. 1971 p 193
  35. Template:Cite web
  36. 36.0 36.1 36.2 Template:Cite web
  37. Template:Cite web
  38. Template:Cite web
  39. Template:Cite web
  40. Template:Cite web
  41. Template:Cite web
  42. Template:Cite web
  43. Dickey, Lee, A list of APL Transliteration Schemes, 1993
  44. Iverson K.E., "Notation as a Tool of Thought", Communications of the ACM, 23: 444-465 (August 1980).
  45. 45.0 45.1 45.2 45.3 45.4 45.5 Template:Cite web
  46. Template:Cite web
  47. 47.0 47.1 47.2 "Programmera i APL", Bohman, Fröberg, Studentlitteratur, ISBN 91-44-13162-3
  48. Quote-Quad newsletterTemplate:Dead link
  49. Template:Cite web

Further reading

|CitationClass=journal }}

  • {{#invoke:Citation/CS1|citation

|CitationClass=journal }}

|CitationClass=book }}

  • {{#invoke:Citation/CS1|citation

|CitationClass=journal }}

  • History of Programming Languages, chapter 14Template:Clarify
  • {{#invoke:citation/CS1|citation

|CitationClass=book }}

  • {{#invoke:citation/CS1|citation

|CitationClass=book }}

External links

Template:Sister