APL (A Programming Language) : Programming with Symbols?
A Programming Language (APL) is named eponymously after a book published by Kenneth E Iverson in 1962.
APL is a unique mathematically-inclined programming language designed for conciseness that was influential in the development of modern spreadsheets and mathematical software packages.
History of APL
In the 1950s, a Harvard University professor created a mathematical notation system that was useful for manipulating complex arrays of information. This professor was Kenneth Iverson.
In 1960, Iverson went to work for IBM where, with the help of computer systems engineer Adin Falkoff, he created a programming language based on the mathematical notation he had developed while working in academia.
This programming language, though impractical to implement at the time, was nonetheless published in the text A Programming Language, and APL was born.
APL was initially used at IBM to perform research on computer systems. However, throughout the 1960s, acceptance of APL was limited by its unusual syntax which includes many graphical symbols which could not be easily represented on computers at that time. As a result, stand-in keyword representations had to be used rather than the actual symbols Iverson had intended.
All of that changed in the late 1960s when IBM released a special typeball which could produce the special symbols used in APL.
IBM simultaneously introduced APL to the computing public by making APL available on IBM mainframe computers. For the next 2 decades, more or less, APL lived on mainframe computers distributed by IBM and other competing hardware and software manufacturers, until personal computer hardware capabilities caught up with the demanding nature of compiling APL.
In the early 1980s, IBM released an updated version of the programming language, APL2, which introduced a number of enhancements including the concept of nested multidimensional arrays.
By 1980 Ken Iverson was no longer in control of APL at IBM and left to join I P Sharp Associates, a competing developer of APL implementations who had just released a proprietary version of the language it called Sharp APL — a product who’s future development they were happy to have Iverson take over.
IBM was able to overcome I P Sharp in establishing their version of APL, APL2, as the industry-standard APL implementation. To this day, modern APL implementations typically cite APL2 compatibility.
According to APL Wiki, there are at least five modern APL implementations:
APL2 2.0, from IBM, is still considered the industry-standard APL implementation.
APLX, from Micro APL, is built on IBM’s APL2 with a number of ehancements.
Dyalog is an APL-based development environment and the most affordably adopted full-featured APL platform.
APL+Win is an APL development environment from APL2000.
NARS2000 is an open-source no-cost feature-limited implementation designed to give those interested in APL the opportunity to try out APL for free.
Some programming languages have been intentionally designed to be easily read by anyone — programmer or not.
Ruby, Python, COBOL, and many other programming languages employ a syntax that can be read, if not really understood, by anyone with a solid grasp of the English language.
APL is not one of these languages.
To anyone unfamiliar with the syntax of the language, APL looks like a series of nonsensical graphical symbols, letters, and numbers.
However, to an APL programmer, each graphical symbol or set of symbols stands in for a mathematical function – often a quite complex function.
In addition to it’s unique syntax, the use of nested multidimensional arrays is another feature that makes APL somewhat unique among programming languages.
Graphical Symbols in APL
Graphical symbols are used to represent functions and operators. Some of the symbols used are common and easily understood:
≠: not equal to
> and <: used to compare two values and return the greater or lesser value
+, −, ÷, and ×: used to perform typical mathematical functions.
The meaning of many other symbols is not readily apparent to non-APL programmers:
⍴: rho, used to return the shape of an array or reshape an array.
⌽: circle stile, reverses the order or an array or rotates an array in a multidimensional direction.
⍋ and ⍒: grade up and grade down, rearranges an array in descending or ascending order.
These are just a few of the dozens of symbols used in APL.
While it may be overwhelming for a beginner to try and take in all of these symbols, their meaning, and how to use them, experienced APL programmers claim greatly enhanced productivity as a result of reduced typing required to create incredibly powerful functions.
Nested Multidimensional Arrays
Simple one-dimenaional arrays are a common data type in computer programming. Arrays are just collections of variables or values. For example,
[0, 1, 2] is an array containing the values 0, 1, and 2.
Multidimensional arrays are made up of multiple rows of array items in a tabular layout. For example, a continuation of the array listed above into a 3 by 3 multidimensional array might look like this:
Nested arrays are another way of enhancing the data contained in an array. In a nested array, each item is capable of containing additional arrays and not just single values or variables.
In APL, arrays can be both multidimensional and contain nested arrays. This can be a little difficult to wrap your head around, so let’s look at an example.
Using the multidimensional array in the example above, we’ll replace the item in the central (2, 2) position (the number 4) with a new multidimensional array consisting of the letters a, b, c, and d.
If the item in the 2, 2 positions in this array were referenced, the array containing the variables a, b, c, and d would be returned.
The ability for arrays to hold nested multidimensional values and variables was added to both Sharp APL and APL2 in the late 1970s and early 1980s, and remains one of the defining features of APL.
Setting up an APL Development Environment
To work with APL you will need to equip your computer to produce APL symbols and install an APL interpreter. To install an APL interpreter, select one of the modern APL implementations listed above.
Our recommendation is to install either NARS2000 or Dyalog. NARS2000 is completely free, but offers a limited feature set.
Dyalog can be downloaded for free (scroll to the bottom of the page and select Download the Unregistered Version), but you’ll want to purchase a registered copy if you end up using APL long-term.
After installing an APL implementation, you will need to set up your machine to produce the symbols required to code in APL. Some APL implementations include a pop-up keyboard menu which you can use to type APL symbols without having to install fonts or purchase new hardware.
If you aren’t ready to go to all of that effort, another option is to try APL in the browser. TryAPL is a free website, created by Dyalog, where you can run APL code in your browser to get a feeling for how APL works.
One of the best places to learn about APL is the APL Wiki. This resource, created collaboratively by the APL community, provides a wealth of educational resources and information about modern APL usage.
If you’re ready to start learning, here are a few of the most useful resources you’ll find at the wiki:
APL in 20 Minutes: a quick look at what APL is and what it can do.
Learning APL: a beginners tutorial that covers the basics of coding in APL.
Hello world: no programming education would be complete without this classic exercise.
Further Topics in APL: if you’ve completed the Learning APL tutorial, this is a great next-step towards APL competency.
Working Practices: if you’ve made it through the previous tutorials, you have a basic grasp of APL, how to use it, and what it can do. The next step is to start working on your own projects. However, before you do that, read about the workflow practices of experienced APL developers.
APL2000 is a bit different from the other APL implementations and can even be used within the .NET Framework with a little additional effort. If this interests you, learn more about VisualAPL from APL200 with these resources:
Two iconic resources in the APL community include an article written by Bernard Legrand in 2006 and the practice of recreating Conway’s Game of Life in APL.
You can read Legrand’s article, APL — a Glimpse of Heaven at Vector, the website for the British APL Association.
Quite a few APL texts have been written over the past five decades. Here are six of the best:
A Programming Language by Kenneth E Iverson, the book that started it all
APL: An Interactive Approach by Gilman and Rose
APL2 in Depth by Thompson and Polivka
APL 2 at a Glance by Brown, Pakin, and Polivka
APL with a Mathematical Accent by Reiter and Jones
Mastering Dyalog APL: A Complete Introduction to Dyalog APL by Bernard Legrand, also available as a free PDF.
APL is a mathematically-inclined programming language whose defining features include a highly symbolic syntax and support for nested multidimensional arrays.
The APL learning curve is nearly vertical, so you’re in for an exceptionally steep climb if you do decide to learn APL.
The payoff is that you’ll be on your way to mastering one of the most powerful programming languages ever designed.
Further Reading and Resources
We have more guides, tutorials, and infographics related to coding and development:
COBOL Introduction and Resources: although it was an earlier language, COBOL is almost the opposite of APL in terms of readability.
Fortran Resources: probably the first high level computer programming language, development on Fortran started almost a decade before APL.
Assembly Language Introduction: learn computer programming at its most basic level.
What Code Should You Learn?
Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn? It not only discusses different aspects of the languages, it answers important questions such as, “How much money will I make programming Java for a living?”