What is Array-oriented Programming?

Also known as vector programming

Most programming languages work on one value at a time. You write a loop, step through your data and handle each item in turn. Array-oriented languages take a different view: the whole collection is the unit of work. You describe what should happen to all of your data, and the language takes care of applying it.

APL was the first array-oriented language, and Dyalog APL is its leading modern implementation.

    Add a header to begin generating the table of contents

    Whole arrays, not individual items

    In APL, an array can be a single number, a list, a table or something with more dimensions. Operations apply to the entire array at once.

          2 × 1 2 3 4 5
    2 4 6 8 10

    There’s no loop to write, no counter to manage and no index to get wrong. The same expression works whether your list has five items or five million.

    Small pieces that combine

    APL gives you a set of primitive functions, each written as a single symbol, that combine into larger ideas. Sum a list with +/. Count its items with ≢. Put them together and you have an average:

          {(+/⍵)÷≢⍵} 3 7 8 10
    7

    Filtering works the same way. Compare each value to 5, then use the result to select:

          v ← 3 9 2 7 6
          (v>5)/v
    9 7 6

    What is APL thinking?

    APL thinking is a habit of mind that grows from working this way. Instead of asking “how do I process each item?”, you ask “what is the shape of this problem?” You start to see data as tables to reshape, masks to apply and patterns to reduce, and solutions that once took pages of code become a single line you can read at a glance.

    Kenneth Iverson, who created APL, called this “notation as a tool of thought”: a well-designed notation doesn’t just record your ideas, it helps you have them. Many programmers, when exposed to APL find that the way they approach problems changes, even when they’re working in other languages.

    Why it matters

    Concise code is easier to reason about, quicker to change and simpler to check against the problem it solves. Domain experts in finance, insurance, logistics and science have used APL for decades to build systems themselves, without translating their knowledge through layers of boilerplate. Array ideas pioneered in APL now appear in tools such as NumPy, R and MATLAB, but APL remains the language built around them from the ground up.

    Videos

    What is APL and What Can APL Do For You?

    Video thumbnail
    Click to load video from YouTube. This will enable YouTube tracking. YouTube Privacy Information

    But How Will I Remember All Those Squiggles?! — APL Mnemonics

    Video thumbnail
    Click to load video from YouTube. This will enable YouTube tracking. YouTube Privacy Information

    Why Would a Non-Programmer Learn APL?

    Video thumbnail
    Click to load video from YouTube. This will enable YouTube tracking. YouTube Privacy Information