APL programming language

APL programming language

Overview
APL is an interactive array-oriented language
Array programming
In computer science, array programming languages generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays....

 and integrated development environment
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...

, which is available from a number of commercial and noncommercial vendors and for most computer platforms. It is based on a mathematical notation
Mathematical notation
Mathematical notation is a system of symbolic representations of mathematical objects and ideas. Mathematical notations are used in mathematics, the physical sciences, engineering, and economics...

 developed by Kenneth E. Iverson
Kenneth E. Iverson
Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

 and associates that features special attributes for the design and specifications of digital computing systems, both hardware
Hardware
Hardware is a general term for equipment such as keys, locks, hinges, latches, handles, wire, chains, plumbing supplies, tools, utensils, cutlery and machine parts. Household hardware is typically sold in hardware stores....

 and software.

APL has a combination of unique and relatively uncommon features that appeal to programmers and make it a productive programming language:
  • It is concise, using symbols rather than words and applying functions to entire arrays without using explicit loops.
  • It is solution focused, emphasizing the expression of algorithms independently of machine architecture or operating system.
  • It has just one simple, consistent, and recursive precedence rule: the right argument of a function is the result of the entire expression to its right.
  • It facilitates problem solving at a high level of abstraction
    Abstraction (computer science)
    In computer science, abstraction is the process by which data and programs are defined with a representation similar to its pictorial meaning as rooted in the more complex realm of human life and language with their higher need of summarization and categorization , while hiding away the...

    .


APL is used in scientific, actuarial, statistical, and financial applications where it is used by practitioners for their own work and by programmers to develop commercial applications.
Discussion
Ask a question about 'APL programming language'
Start a new discussion about 'APL programming language'
Answer questions from other users
Full Discussion Forum
 
Unanswered Questions
Encyclopedia
APL is an interactive array-oriented language
Array programming
In computer science, array programming languages generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays....

 and integrated development environment
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...

, which is available from a number of commercial and noncommercial vendors and for most computer platforms. It is based on a mathematical notation
Mathematical notation
Mathematical notation is a system of symbolic representations of mathematical objects and ideas. Mathematical notations are used in mathematics, the physical sciences, engineering, and economics...

 developed by Kenneth E. Iverson
Kenneth E. Iverson
Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

 and associates that features special attributes for the design and specifications of digital computing systems, both hardware
Hardware
Hardware is a general term for equipment such as keys, locks, hinges, latches, handles, wire, chains, plumbing supplies, tools, utensils, cutlery and machine parts. Household hardware is typically sold in hardware stores....

 and software.

APL has a combination of unique and relatively uncommon features that appeal to programmers and make it a productive programming language:
  • It is concise, using symbols rather than words and applying functions to entire arrays without using explicit loops.
  • It is solution focused, emphasizing the expression of algorithms independently of machine architecture or operating system.
  • It has just one simple, consistent, and recursive precedence rule: the right argument of a function is the result of the entire expression to its right.
  • It facilitates problem solving at a high level of abstraction
    Abstraction (computer science)
    In computer science, abstraction is the process by which data and programs are defined with a representation similar to its pictorial meaning as rooted in the more complex realm of human life and language with their higher need of summarization and categorization , while hiding away the...

    .


APL is used in scientific, actuarial, statistical, and financial applications where it is used by practitioners for their own work and by programmers to develop commercial applications. It was an important influence on the development of spreadsheet
Spreadsheet
A spreadsheet is a computer application that simulates a paper accounting worksheet. It displays multiple cells usually in a two-dimensional matrix or grid consisting of rows and columns. Each cell contains alphanumeric text, numeric values or formulas...

s, functional programming
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

, and computer math packages. It has also inspired several other programming languages. It is also associated with rapid and lightweight development projects in volatile business environments.

History


The first incarnation of what was later to be the APL programming language was published and formalized in A Programming Language, a book describing a notation invented in 1957 by Kenneth E. Iverson
Kenneth E. Iverson
Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

 while at Harvard University
Harvard University
Harvard University is a private Ivy League university located in Cambridge, Massachusetts, United States, established in 1636 by the Massachusetts legislature. Harvard is the oldest institution of higher learning in the United States and the first corporation chartered in the country...

. Iverson had developed a mathematical notation
Mathematical notation
Mathematical notation is a system of symbolic representations of mathematical objects and ideas. Mathematical notations are used in mathematics, the physical sciences, engineering, and economics...

 for manipulating arrays that he taught to his students.

In 1960, he began work for IBM and working with Adin Falkoff
Adin Falkoff
Adin D. Falkoff Born in New Jersey, a researcher and manager at IBM Research since the 1950s for over forty years before retiring. He collaborated with Ken Iverson from 1960 to 1980 on the design, development, and usage of the APL programming language and its interactive environment...

, 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
Burroughs B5000
In the 1970s, Burroughs Corporation was organized into three divisions with very different product line architectures for high-end, mid-range, and entry-level business computer systems...

 and its stack mechanism when stack machines versus register machine
Register machine
In mathematical logic and theoretical computer science a register machine is a generic class of abstract machines used in a manner similar to a Turing machine...

s were being evaluated by IBM for upcoming computers.

Also in 1960, Iverson was already also using his notation in a draft copy of Chapter 6 called "A programming language" for the book he was writing with Fred Brooks
Fred Brooks
Frederick Phillips Brooks, Jr. is a software engineer and computer scientist, best known for managing the development of IBM's System/360 family of computers and the OS/360 software support package, then later writing candidly about the process in his seminal book The Mythical Man-Month...

, Automatic Data Processing, which would later be published in 1963.

Published in 1962, the notation described in A Programming Language 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
IBM 1620
The IBM 1620 was announced by IBM on October 21, 1959, and marketed as an inexpensive "scientific computer". After a total production of about two thousand machines, it was withdrawn on November 19, 1970...

 computer, and it was used by students in a special high school course on elementary functions. This implementation of a portion of the notation was called PAT (Personalized Array Translator).

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
Science Research Associates
Founded in 1938, SRA or Science Research Associates Inc. is a Chicago-based publisher of educational materials and schoolroom reading comprehension products. Early on, it had a trade and occupational focus...

, 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.

After Lawrence M. Breed
Lawrence M. Breed
Lawrence M. Breed is a computer scientist, artist and inventor, best known for his involvement in the APL programming language.- Career :While at Stanford University in 1961, he created the first computer animation language, MACS, and demonstrated it publicly with Earl Boebert.While getting his M.S...

 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
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

 for a portion of the notation was done for the IBM 7090
IBM 7090
The IBM 7090 was a second-generation transistorized version of the earlier IBM 709 vacuum tube mainframe computers and was designed for "large-scale scientific and technological applications". The 7090 was the third member of the IBM 700/7000 series scientific computers. The first 7090 installation...

 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. 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.


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
IBM Selectric typewriter
The IBM Selectric typewriter was a highly successful model line of electric typewriters introduced by IBM on July 31, 1961.Instead of the "basket" of individual typebars that swung up to strike the ribbon and page in a traditional typewriter, the Selectric had a type element that rotated and...

 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
IBM 1050
IBM 1050 Data Communications System is a computer terminal subsystem to send data to and receive data from another 1050 subsystem or IBM computer in the IBM 1400, IBM 7000 or System/360 series. It first became available in 1963 and was used widely during the 1960s.-General:IBM 1050 Data...

 and IBM 2741
IBM 2741
The IBM 2741 was a printing computer terminal introduced in 1965.It combined a ruggedized Selectric typewriter mechanism with IBM SLT electronics and an RS-232-C serial interface. It operated at about 14.1 characters per second with a data rate of 134.5 bits/second...

 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. Iverson cited Falkoff as the inspiration for the idea of using an IBM Selectric typeball for the APL character set.

The IBM 2741 keyboard layout with the APL typeball print head inserted looked this way to the programmer:


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
Sheffer stroke
In Boolean functions and propositional calculus, the Sheffer stroke, named after Henry M. Sheffer, written "|" , "Dpq", or "↑", denotes a logical operation that is equivalent to the negation of the conjunction operation, expressed in ordinary language as "not both"...

" (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 a 1050 terminal at the IBM Mohansic Labs near Thomas J. Watson Research Center
Thomas J. Watson Research Center
The Thomas J. Watson Research Center is the headquarters for the IBM Research Division.The center is on three sites, with the main laboratory in Yorktown Heights, New York, 38 miles north of New York City, a building in Hawthorne, New York, and offices in Cambridge, Massachusetts.- Overview :The...

, the home of APL, in Yorktown Heights, New York
Yorktown Heights, New York
Yorktown Heights is a census-designated place in the town of Yorktown in Westchester County, New York, United States. The population was 1,781 at the 2010 census.-Geography:Yorktown Heights is located at ....

.

IBM was chiefly responsible for the introduction of APL to the marketplace.

APL was first available in 1967 for the IBM 1130
IBM 1130
The IBM 1130 Computing System was introduced in 1965. It was IBM's least-expensive computer to date, and was aimed at price-sensitive, computing-intensive technical markets like education and engineering. It succeeded the IBM 1620 in that market segment. The IBM 1800 was a process control variant...

 as APL\1130. 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. Additional improvements in performance for selected IBM 370
IBM 370
The IBM 370 printer was used on the IBM 305 RAMAC computer system, introduced by IBM on September 14, 1956. The 370 was connected to the 305 by a serial data line from the S track of the computer's drum memory and printed 80-columns with a punched tape controlled carriage...

 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
IBM 370
The IBM 370 printer was used on the IBM 305 RAMAC computer system, introduced by IBM on September 14, 1956. The 370 was connected to the 305 by a serial data line from the S track of the computer's drum memory and printed 80-columns with a punched tape controlled carriage...

 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
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.

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
IBM 5100
The IBM 5100 Portable Computer was a portable computer introduced in September 1975, six years before the IBM PC. It was the evolution of a prototype called the SCAMP that was developed at the IBM Palo Alto Scientific Center in 1973. In January 1978 IBM announced the IBM 5110, its larger cousin,...

 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
Conversational Monitor System
The Conversational Monitor System is a relatively simple interactive computing single-user operating system.* CMS is part of IBM's VM family, which runs on IBM mainframe computers...

, TSO
Time Sharing Option
In computing, Time Sharing Option is an interactive time-sharing environment for IBM mainframe operating systems, including OS/360 MVT, OS/VS2 , MVS, OS/390, and z/OS.- Overview :TSO fulfills a similar purpose to Unix login sessions...

, VSPC, MUSIC/SP
MUSIC/SP
MUSIC/SP was developed at McGill University in the 1970s from an early IBM time-sharing system called RAX...

 and CICS
CICS
Customer Information Control System is a transaction server that runs primarily on IBM mainframe systems under z/OS and z/VSE.CICS is a transaction manager designed for rapid, high-volume online processing. This processing is mostly interactive , but background transactions are possible...

 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. At the time, Sperry had nothing. In 1974, student Alan Stebbens was assigned the task of implementing an internal function. And student Bill Linton caused massive dumps to occur as he practiced developing APL programs in the third-floor TTY room, causing Dr. Hagerty to burst through the TTY door to halt the practice until Dr. Hagerty fixed the APL interpreter bug.

Several timesharing firms sprang up in the 1960s and 1970s that sold APL services using modified versions of the IBM APL\360 interpreter. In North America, the better-known ones were I. P. Sharp Associates
I. P. Sharp Associates
I. P. Sharp Associates, IPSA for short, was a major Canadian computer time sharing, consulting and services firm of the 1970s and 80s. IPSA is particularly well known for its work on the APL programming language, an early packet switching computer network known as IPSANET, and a powerful...

, Scientific Time Sharing Corporation
Scientific Time Sharing Corporation
Scientific Time Sharing Corporation was a pioneering timesharing and consulting service company which offered APL from its datacenter in Bethesda, MD to users in the United States and Europe.-History:...

, 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
I. P. Sharp Associates
I. P. Sharp Associates, IPSA for short, was a major Canadian computer time sharing, consulting and services firm of the 1970s and 80s. IPSA is particularly well known for its work on the APL programming language, an early packet switching computer network known as IPSANET, and a powerful...

, 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
Control Data Corporation
Control Data Corporation was a supercomputer firm. For most of the 1960s, it built the fastest computers in the world by far, only losing that crown in the 1970s after Seymour Cray left the company to found Cray Research, Inc....

, Data General
Data General
Data General was one of the first minicomputer firms from the late 1960s. Three of the four founders were former employees of Digital Equipment Corporation. Their first product, the Data General Nova, was a 16-bit minicomputer...

, DEC
Digital Equipment Corporation
Digital Equipment Corporation was a major American company in the computer industry and a leading vendor of computer systems, software and peripherals from the 1960s to the 1990s...

, Harris
Harris Corporation
Harris Corporation is a Florida-based international communications equipment company that produces wireless equipment, electronic systems, and both terrestrial and spaceborne antennas for use in the government, defense, and commercial sectors. It is also the largest private-sector employer in...

, Hewlett-Packard
Hewlett-Packard
Hewlett-Packard Company or HP is an American multinational information technology corporation headquartered in Palo Alto, California, USA that provides products, technologies, softwares, solutions and services to consumers, small- and medium-sized businesses and large enterprises, including...

, Siemens
Siemens AG
Siemens AG is a German multinational conglomerate company headquartered in Munich, Germany. It is the largest Europe-based electronics and electrical engineering company....

, Xerox
Xerox
Xerox Corporation is an American multinational document management corporation that produced and sells a range of color and black-and-white printers, multifunction systems, photo copiers, digital production printing presses, and related consulting services and supplies...

, and others.

Garth Foster of Syracuse University
Syracuse University
Syracuse University is a private research university located in Syracuse, New York, United States. Its roots can be traced back to Genesee Wesleyan Seminary, founded by the Methodist Episcopal Church in 1832, which also later founded Genesee College...

 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
Asilomar Conference Grounds
Asilomar Conference Grounds is a conference center built for the YWCA in 1913 at Asilomar State Beach in Pacific Grove, California. Julia Morgan designed and built 16 of the buildings on the property, of which 11 are still standing. It became part of Asilomar State Beach and Conference Grounds in...

 near Monterey, California, and at Pajaro Dunes near Watsonville, California. The SIGAPL special interest group of the Association for Computing Machinery
Association for Computing Machinery
The Association for Computing Machinery is a learned society for computing. It was founded in 1947 as the world's first scientific and educational computing society. Its membership is more than 92,000 as of 2009...

 continues to support the APL community.

In 1979, Iverson received the Turing Award
Turing Award
The Turing Award, in full The ACM A.M. Turing Award, is an annual award given by the Association for Computing Machinery to "an individual selected for contributions of a technical nature made to the computing community. The contributions should be of lasting and major technical importance to the...

 for his work on APL.

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
I. P. Sharp Associates
I. P. Sharp Associates, IPSA for short, was a major Canadian computer time sharing, consulting and services firm of the 1970s and 80s. IPSA is particularly well known for its work on the APL programming language, an early packet switching computer network known as IPSANET, and a powerful...

, where one of his major contributions was directing the evolution of Sharp APL to be more in accordance with his vision.

As other vendors were busy developing APL interpreters for new hardware, notably Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

-based microcomputer
Microcomputer
A microcomputer is a computer with a microprocessor as its central processing unit. They are physically small compared to mainframe and minicomputers...

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.

APL2 for IBM mainframe computers is still available today, and was first available for CMS
Conversational Monitor System
The Conversational Monitor System is a relatively simple interactive computing single-user operating system.* CMS is part of IBM's VM family, which runs on IBM mainframe computers...

 and TSO
Time Sharing Option
In computing, Time Sharing Option is an interactive time-sharing environment for IBM mainframe operating systems, including OS/360 MVT, OS/VS2 , MVS, OS/390, and z/OS.- Overview :TSO fulfills a similar purpose to Unix login sessions...

 in 1984. The APL2 Workstation edition (Windows, OS/2, AIX, Linux, and Solaris) followed much later in the early 1990s.

Microcomputers


The first microcomputer implementation of APL was on the 8008
Intel 8008
The Intel 8008 was an early byte-oriented microprocessor designed and manufactured by Intel and introduced in April 1972. It was an 8-bit CPU with an external 14-bit address bus that could address 16KB of memory...

-based MCM/70
MCM/70
The MCM/70 was a pioneering microcomputer first built in 1973 and released the next year, making it one of the first microcomputers in the world, the second to be shipped in completed form, the first portable computer, and arguably the first truly usable microcomputer system...

, the first general purpose personal computer, in 1973.

IBM's own IBM 5100
IBM 5100
The IBM 5100 Portable Computer was a portable computer introduced in September 1975, six years before the IBM PC. It was the evolution of a prototype called the SCAMP that was developed at the IBM Palo Alto Scientific Center in 1973. In January 1978 IBM announced the IBM 5110, its larger cousin,...

 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
VideoBrain Family Computer
The VideoBrain Family Computer is an 8-bit home computer manufactured by the VideoBrain Computer Company, starting in 1977. It is based on the Fairchild Semiconductor F8 CPU and is notable for being the first fully programmable cartridge-based home computer...

, released in 1977, only had one programming language available for it and that was a dialect of APL called APL/S.

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 ~. prefix to all single character dyadic functions such as - or /.

Vanguard APL was available for Z80 CP/M
CP/M
CP/M was a mass-market operating system created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc...

-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
APLX
APLX is a modern, second generation, cross-platform dialect of the APL programming language. APLX is targeted at applications such as financial planning, market research, statistics, management information, and various kinds of scientific and engineering work. APLX is based on IBM's APL2, but...

 product. I. P. Sharp Associates released a version of their APL interpreter for the IBM PC and PC/370 - for the IBM PC, an emulator
Emulator
In computing, an emulator is hardware or software or both that duplicates the functions of a first computer system in a different second computer system, so that the behavior of the second system closely resembles the behavior of the first system...

 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
Scientific Time Sharing Corporation
Scientific Time Sharing Corporation was a pioneering timesharing and consulting service company which offered APL from its datacenter in Bethesda, MD to users in the United States and Europe.-History:...

's APL*Plus/PC.

The Commodore SuperPET
Commodore PET
The Commodore PET was a home/personal computer produced from 1977 by Commodore International...

, introduced in 1981, included an APL interpreter developed by the University of Waterloo
University of Waterloo
The University of Waterloo is a comprehensive public university in the city of Waterloo, Ontario, Canada. The school was founded in 1957 by Drs. Gerry Hagey and Ira G. Needles, and has since grown to an institution of more than 30,000 students, faculty, and staff...

.

In the early 1980s, the Analogic Corporation developed The APL Machine, which was an array processing
Vector processor
A vector processor, or array processor, is a central processing unit that implements an instruction set containing instructions that operate on one-dimensional arrays of data called vectors. This is in contrast to a scalar processor, whose instructions operate on single data items...

 computer designed to be programmed only in APL. There were actually three processing units, the user's workstation, an IBM PC
IBM PC
The IBM Personal Computer, commonly known as the IBM PC, is the original version and progenitor of the IBM PC compatible hardware platform. It is IBM model number 5150, and was introduced on August 12, 1981...

, where programs were entered and edited, a Motorola 6800
Motorola 6800
The 6800 was an 8-bit microprocessor designed and first manufactured by Motorola in 1974. The MC6800 microprocessor was part of the M6800 Microcomputer System that also included serial and parallel interface ICs, RAM, ROM and other support chips...

 processor that ran the APL interpreter, and the Analogic array processor that executed the primitives. 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, Microsoft Corporation planned to release a version of APL, but these plans never materialized.

An early 1978 publication of Rodnay Zaks
Rodnay Zaks
Rodnay Zaks is a French-born American author of many books on computer programming, including the seminal Programming the Z80 and Programming the 6502...

 from Sybex was A microprogrammed APL implementation ISBN 0895880059, 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.

Extensions


Recent extensions to APL include:
  • Object-oriented programming
    Object-oriented programming
    Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

  • Support for .Net
    .NET Framework
    The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

    , ActiveX, operating system resources & connectivity
  • APL as a native .NET language using Visual Studio 2008
  • Integrated charting and manipulation of SQL databases
  • XML-array conversion primitives
  • Lambda expressions

Overview


Over a very wide set of problem domains (math, science, engineering, computer design, robotics, data visualization, actuarial science, traditional DP, etc.) APL is an extremely powerful, expressive and concise programming language, typically set in an interactive environment. It was originally created, among other things, as a way to describe computers, by expressing mathematical notation
Mathematical notation
Mathematical notation is a system of symbolic representations of mathematical objects and ideas. Mathematical notations are used in mathematics, the physical sciences, engineering, and economics...

 in a rigorous way that could be interpreted by a computer. It is easy to learn but some APL programs can take some time to understand, especially for a newcomer. Few other programming languages offer the comprehensive array functionality of APL.

Unlike traditionally structured programming languages, code in APL is typically structured as chains of monadic
Unary operation
In mathematics, a unary operation is an operation with only one operand, i.e. a single input. Specifically, it is a functionf:\ A\to Awhere A is a set. In this case f is called a unary operation on A....

 or dyadic
Binary operation
In mathematics, a binary operation is a calculation involving two operands, in other words, an operation whose arity is two. Examples include the familiar arithmetic operations of addition, subtraction, multiplication and division....

 functions and operator
Higher-order function
In mathematics and computer science, higher-order functions, functional forms, or functionals are functions which do at least one of the following:*take one or more functions as an input*output a function...

s acting on arrays
Array data type
In computer science, an array type is a data type that is meant to describe a collection of elements , each selected by one or more indices that can be computed at run time by the program. Such a collection is usually called an array variable, array value, or simply array...

. 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
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

 (do or while loops, if-then-else), but by using array operations, usage of structured programming
Structured programming
Structured programming is a programming paradigm aimed on improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures and for and while loops - in contrast to using simple tests and jumps such as the goto statement which could...

 constructs was just not necessary. For example, the iota function (which yields a one-dimensional array, or vector, from 1 to N) can replace for-loop iteration
Iteration
Iteration means the act of repeating a process usually with the aim of approaching a desired goal or target or result. Each repetition of the process is also called an "iteration," and the results of one iteration are used as the starting point for the next iteration.-Mathematics:Iteration in...

. 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,


assigns the vector
Coordinate vector
In linear algebra, a coordinate vector is an explicit representation of a vector in an abstract vector space as an ordered list of numbers or, equivalently, as an element of the coordinate space Fn....

 values 4 5 6 7 to N;


adds 4 to all values (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);


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

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
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 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
Conway's Game of Life
The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970....

 in one line of code (example). 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.

Because of its condensed nature and non-standard characters, APL has sometimes been termed a "write-only language
Write-only language
A write-only language is a programming language with syntax sufficiently dense and bizarre that any routine of significant size is automatically write-only code...

", and reading an APL program can at first feel like decoding Egyptian hieroglyphics. Because of the unusual character set, many programmers use special keyboards
Computer keyboard
In computing, a keyboard is a typewriter-style keyboard, which uses an arrangement of buttons or keys, to act as mechanical levers or electronic switches...

 with APL keytops for authoring APL code. Although there are various ways to write APL code using only ASCII characters, in practice, it is almost never done. (This may be thought to support Iverson's thesis about notation as a tool of thought
Linguistic relativity
The principle of linguistic relativity holds that the structure of a language affects the ways in which its speakers are able to conceptualize their world, i.e. their world view...

.) Most if not all modern implementations use standard keyboard layouts, with special mappings or input method editor
Input method editor
An input method is an operating system component or program that allows any data, such as keyboard strokes or mouse movements, to be received as input. In this way users can enter characters and symbols not found on their input devices...

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 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
COBOL
COBOL is one of the oldest programming languages. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments....

 and Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

, as comparatively tedious. APL is often found where time-to-market is important, such as with trading systems.

Iverson later designed the J programming language, which uses ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 with digraphs instead of special symbols.

Interpreters


Today, most APL language activity takes place under the Microsoft Windows operating system, with some activity under Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

, Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

, and Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

. Comparatively little APL activity takes place today on mainframe computers.

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
Scientific Time Sharing Corporation
Scientific Time Sharing Corporation was a pioneering timesharing and consulting service company which offered APL from its datacenter in Bethesda, MD to users in the United States and Europe.-History:...

'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
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 features, numerous language enhancements, plus a consistent namespace
Namespace
In general, a namespace is a container that provides context for the identifiers it holds, and allows the disambiguation of homonym identifiers residing in different namespaces....

 model used for both its Microsoft Automation interface, as well as native namespaces. For the Windows platform, Dyalog APL offers tight integration with Microsoft .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
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 and Apple Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

 with Wine
Wine (software)
Wine is a free software application that aims to allow computer programs written for Microsoft Windows to run on Unix-like operating systems. Wine also provides a software library, known as Winelib, against which developers can compile Windows applications to help port them to Unix-like...

.

MicroAPL Limited offers APLX
APLX
APLX is a modern, second generation, cross-platform dialect of the APL programming language. APLX is targeted at applications such as financial planning, market research, statistics, management information, and various kinds of scientific and engineering work. APLX is based on IBM's APL2, but...

, a full-featured 64 bit interpreter for Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

, Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

, and Apple Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

 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
Soliton Incorporated
Soliton Incorporated was a company formed in 1993 to continue the support and development of Sharp APL, originally developed by I. P. Sharp Associates, and other related products and services.-History:...

 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
Kenneth E. Iverson
Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

 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.

Compilers


APL programs are normally interpreted
Interpreted language
Interpreted language is a programming language in which programs are 'indirectly' executed by an interpreter program. This can be contrasted with a compiled language which is converted into machine code and then 'directly' executed by the host CPU...

 and less often compiled
Compiled language
A compiled language is a programming language whose implementations are typically compilers , and not interpreters ....

. In reality, most APL compilers translated source APL to a lower level language such as C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, 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
Reflection (computer science)
In computer science, reflection is the process by which a computer program can observe and modify its own structure and behavior at runtime....

 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
Scientific Time Sharing Corporation
Scientific Time Sharing Corporation was a pioneering timesharing and consulting service company which offered APL from its datacenter in Bethesda, MD to users in the United States and Europe.-History:...

 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
Timothy Budd
Timothy Budd is an associate professor of computer science at Oregon State University. He is the author of more than a dozen books on object-oriented programming, data structures, and Leda, a multi-paradigm programming language, some of which are published in multiple languages...

 appeared in print. This book detailed the construction of an APL translator, written in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, which performed certain optimizations such as loop fusion
Loop fusion
Loop fusion, also called loop jamming, is a compiler optimization, a loop transformation, which replaces multiple loops with a single one.- Example in C : int i, a[100], b[100]; for Loop fusion, also called loop jamming, is a compiler optimization, a loop transformation, which replaces multiple...

 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
Parsing
In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a text, made of a sequence of tokens , to determine its grammatical structure with respect to a given formal grammar...

 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
SAC programming language
SAC is a strict purely functional programming language which design is focused on the needs of numerical applications. Emphasis is laid on efficient support for array processing. Efficiency concerns are essentially twofold...

, a functional array language with parallel semantics, and currently runs under Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

. APEX-generated code uses loop fusion
Loop fusion
Loop fusion, also called loop jamming, is a compiler optimization, a loop transformation, which replaces multiple loops with a single one.- Example in C : int i, a[100], b[100]; for Loop fusion, also called loop jamming, is a compiler optimization, a loop transformation, which replaces multiple...

 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
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

.

The APLNext VisualAPL system is a departure from a conventional APL system in that VisualAPL is a true .Net language, which is fully inter-operable with other .Microsoft .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 .Net common language runtime (CLR) 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, 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.

A source of links to existing compilers is at APL2C.

Matrix optimizations


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. 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
    Microcode
    Microcode is a layer of hardware-level instructions and/or data structures involved in the implementation of higher level machine code instructions in many computers and other processors; it resides in special high-speed memory and translates machine instructions into sequences of detailed...

     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
Lazy evaluation
In programming language theory, lazy evaluation or call-by-need is an evaluation strategy which delays the evaluation of an expression until the value of this is actually required and which also avoids repeated evaluations...

 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-vectors 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
American National Standards Institute
The American National Standards Institute is a private non-profit organization that oversees the development of voluntary consensus standards for products, services, processes, systems, and personnel in the United States. The organization also coordinates U.S. standards with international...

 working group
Working group
A working group is an interdisciplinary collaboration of researchers working on new research activities that would be difficult to develop under traditional funding mechanisms . The lifespan of the WG can last anywhere between a few months and several years...

 X3J10, APL remains highly data-parallel
Data parallelism
Data parallelism is a form of parallelization of computing across multiple processors in parallel computing environments. Data parallelism focuses on distributing the data across different parallel computing nodes...

. This gives language implementers immense freedom to schedule operations as efficiently as possible. As computer innovations such as cache memory, and SIMD
SIMD
Single instruction, multiple data , is a class of parallel computers in Flynn's taxonomy. It describes computers with multiple processing elements that perform the same operation on multiple data simultaneously...

 execution became commercially available, APL programs ported with almost no extra effort spent re-optimizing low-level details.

Terminology


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
Higher-order function
In mathematics and computer science, higher-order functions, functional forms, or functionals are functions which do at least one of the following:*take one or more functions as an input*output a 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' & ('adverb' or 'conjunction') for 'function' and '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.

Examples


This displays "Hello, world":

'Hello, world'

This following immediate-mode expression generates a typical set of Pick 6 lottery
Lottery
A lottery is a form of gambling which involves the drawing of lots for a prize.Lottery is outlawed by some governments, while others endorse it to the extent of organizing a national or state lottery. It is common to find some degree of regulation of lottery by governments...

 numbers: six pseudo-random integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

s 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 first 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.

(Note 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
Role-playing game
A role-playing game is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting out these roles within a narrative, either through literal acting, or through a process of structured decision-making or character development...

 program might use the expression "?20" to roll a twenty-sided die.)

The following expression sorts
Sorting
Sorting is any process of arranging items in some sequence and/or in different sets, and accordingly, it has two common, yet distinct meanings:# ordering: arranging items of the same kind, class, nature, etc...

 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
Conway's Game of Life
The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970....

. 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←'

This is emphasized text

'
⎕←{⍵⍨~{⍵∨≠\⍵}⍵∊'<>'}txt
This is emphasized text

The following expression finds all prime number
Prime number
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2...

s from 1 to R. In both time and space, the calculation complexity is O(R²) (in Big O notation
Big O notation
In mathematics, big O notation is used to describe the limiting behavior of a function when the argument tends towards a particular value or infinity, usually in terms of simpler functions. It is a member of a larger family of notations that is called Landau notation, Bachmann-Landau notation, or...

).

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

Executed from right to left, this means:
  • ιR creates a vector containing integer
    Integer
    The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

    s 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
  • Generate outer product
    Outer product
    In linear algebra, the outer product typically refers to the tensor product of two vectors. The result of applying the outer product to a pair of vectors is a matrix...

     of R multiplied by R, i.e. a matrix that is the multiplication table
    Multiplication table
    In mathematics, a multiplication table is a mathematical table used to define a multiplication operation for an algebraic system....

     of R by R (°.× function), i.e.
{| style="text-align:right; background:white"

|-
| 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 the values in the vector (change zeros to ones and ones to zeros) (∼, negation function), i.e. 1 1 0 1 0
  • Select the items in R for which the corresponding element is 1 (/ 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.)

Character set



APL has always been criticized for its choice of a unique, non-standard character set. The observation that some who learn it usually become ardent adherents shows that there is some weight behind Iverson
Kenneth E. Iverson
Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

'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
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...

 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
Unicode
Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems...

 support, the APL character font problem has largely been eliminated; however, the problem of entering APL characters requires the use of input method editor
Input method editor
An input method is an operating system component or program that allows any data, such as keyboard strokes or mouse movements, to be received as input. In this way users can enter characters and symbols not found on their input devices...

s or special keyboard mappings, which may frustrate beginners accustomed to other programming languages.

Usage


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).

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 timesharing
Time-sharing
Time-sharing is the sharing of a computing resource among many users by means of multiprogramming and multi-tasking. Its introduction in the 1960s, and emergence as the prominent model of computing in the 1970s, represents a major technological shift in the history of computing.By allowing a large...

 vendors delivered applications in this form. On the I. P. Sharp
I. P. Sharp Associates
I. P. Sharp Associates, IPSA for short, was a major Canadian computer time sharing, consulting and services firm of the 1970s and 80s. IPSA is particularly well known for its work on the APL programming language, an early packet switching computer network known as IPSANET, and a powerful...

 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
Tron
-Film:*Tron , a franchise that began in 1982 with the Walt Disney Pictures film Tron** Tron , a 1982 science fiction film by Disney, starring Jeff Bridges, Bruce Boxleitner, Cindy Morgan, Dan Shor and David Warner...

.

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
Microsoft Excel
Microsoft Excel is a proprietary commercial spreadsheet application written and distributed by Microsoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications...

 and Microsoft Access
Microsoft Access
Microsoft Office Access, previously known as Microsoft Access, is a relational database management system from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software-development tools. It is a member of the Microsoft Office suite of...

 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
MATLAB
MATLAB is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages,...

, GNU Octave
GNU Octave
GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command-line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB...

, and Scilab
Scilab
Scilab is an open source, cross-platform numerical computational package and a high-level, numerically oriented programming language. Itcan be used for signal processing, statistical analysis, image enhancement, fluid dynamics simulations, numerical optimization, and modeling and simulation of...

. 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.

Standardization


APL has been standardized by the ANSI
American National Standards Institute
The American National Standards Institute is a private non-profit organization that oversees the development of voluntary consensus standards for products, services, processes, systems, and personnel in the United States. The organization also coordinates U.S. standards with international...

 working group
Working group
A working group is an interdisciplinary collaboration of researchers working on new research activities that would be difficult to develop under traditional funding mechanisms . The lifespan of the WG can last anywhere between a few months and several years...

 X3J10 and ISO
International Organization for Standardization
The International Organization for Standardization , widely known as ISO, is an international standard-setting body composed of representatives from various national standards organizations. Founded on February 23, 1947, the organization promulgates worldwide proprietary, industrial and commercial...

/IEC
International Electrotechnical Commission
The International Electrotechnical Commission is a non-profit, non-governmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies – collectively known as "electrotechnology"...

 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.

Glossary


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;
Defined - as a named and ordered collection of program statements;
Derived - as a combination of an operator with its arguments.
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.
niladic not taking or requiring any arguments,
monadic requiring only one argument; on the right for a function, on the left for an operator, unary
dyadic requiring both a left and a right argument, binary
ambivalent or nomadic capable of use in a monadic or dyadic context, permitting its left argument to be elided
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;
Defined - as a named and ordered collection of program statements.

Criticism


APL has been used since the mid 1960s on mainframe computers and has itself evolved in step with computers and the computing market. APL is not widely used, but minimalistic and high-level by design, at several points in its history it could have captured a more significant market share, but never did. APL first appeared on large mainframe computers and, like C and Pascal, did find its way to CP/M and MS-DOS based microcomputers. Unlike C and Pascal, APL did not flourish in the microcomputer arena until hardware of sufficient computing power became commonly available. Perhaps accounting for its lack of mainstream appeal, APL's characteristics have always led to much criticism of the language. As always, such complaints may arise from misconceptions, have origins in distant APL history and no longer be relevant today, or they may have some degree of validity.

See also

  • A+
    A+ (programming language)
    A+ is an array programming language descendent from the programming language A, which in turn was created to replace APL in 1988. Arthur Whitney developed the "A" portion of A+, while other developers at Morgan Stanley extended it, adding a graphical user interface and other language features...

    , a dialect of APL with extensive extensions
  • APL Shared Variables
    APL Shared Variables
    Shared Variables are a feature of the APL language which allowed mainframe APL programs to communicate with other facilities on a computer, which could include external files, DBMS, or other users...

  • IBM Type-III Library
    IBM Type-III Library
    The IBM Type-III Library was software provided by IBM to its customers, available without charge, liability, or support, and typically in source-code format...

  • IBM 1130
    IBM 1130
    The IBM 1130 Computing System was introduced in 1965. It was IBM's least-expensive computer to date, and was aimed at price-sensitive, computing-intensive technical markets like education and engineering. It succeeded the IBM 1620 in that market segment. The IBM 1800 was a process control variant...

    , APL \ 1130 was an early implementation (1968) of APL on the IBM 1130
  • I. P. Sharp Associates
    I. P. Sharp Associates
    I. P. Sharp Associates, IPSA for short, was a major Canadian computer time sharing, consulting and services firm of the 1970s and 80s. IPSA is particularly well known for its work on the APL programming language, an early packet switching computer network known as IPSANET, and a powerful...

  • Iverson Award
    Iverson Award
    The Iverson Award, more formally the Kenneth E. Iverson Award for Outstanding Contribution to APL, is presented by the Special Interest Group on APL of the Association for Computing Machinery . It is presented to a person who has made significant contributions to the APL programming language or to...

  • J
    J (programming language)
    The J programming language, developed in the early 1990s by Kenneth E. Iverson and Roger Hui, is a synthesis of APL and the FP and FL function-level languages created by John Backus....

    , also created by Kenneth E. Iverson
    Kenneth E. Iverson
    Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

    , the creator of APL
  • LYaPAS
    LYaPAS
    LYaPAS is a programming language created in the Soviet Union in 1964 by Arkady D.Zakrevskij of the Laboratory of System Programming and Logical Synthesis of the BSSR Academy of Sciences.LYaPAS is an extension to APL, and was initially designed to program the URAL-1 computer...

  • Soliton Incorporated
    Soliton Incorporated
    Soliton Incorporated was a company formed in 1993 to continue the support and development of Sharp APL, originally developed by I. P. Sharp Associates, and other related products and services.-History:...

    , a continuation of I. P. Sharp Associates' software unit
  • STSC
    Scientific Time Sharing Corporation
    Scientific Time Sharing Corporation was a pioneering timesharing and consulting service company which offered APL from its datacenter in Bethesda, MD to users in the United States and Europe.-History:...

    , company formed to commercialize APL

Further reading

  • An APL Machine (1970 Stanford doctoral dissertation by Philip Abrams)
  • A Personal History Of APL (1982 article by Michael S. Montalbano
    Michael S. Montalbano
    Michael S. Montalbano was a computer scientist most noted for authoring "APL Blossom Time", a poem about the early days of the APL programming language, performed to the tune of The Battle of New Orleans. He published this poem and a few other articles under the pseudonym "J. C. L...

    )
  • A Programming Language by Kenneth E. Iverson
    Kenneth E. Iverson
    Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

  • APL in Exposition by Kenneth E. Iverson
    Kenneth E. Iverson
    Kenneth Eugene Iverson was a Canadian computer scientist noted for the development of the APL programming language in 1962. He was honored with the Turing Award in 1979 for his contributions to mathematical notation and programming language theory...

  • Brooks, Frederick P.; Kenneth Iverson (1965). Automatic Data Processing, System/360 Edition. ISBN 0-471-10605-4.

External links