APL Project

Here is the top level overview of the APL Project - My attempt at writing an APL interpreter.

Why writing APL in JavaScript?

Now an APL interpreter is available on any platform: PC, laptop, tablet, smartphone. No internet connection required once HTML page and JavaScript modules are saved on your device for offline viewing.

● Free. No licensing fees or restrictions even if it's used to make "commercial" programs, if that's a thing.

● Runs with decent performance so that it can be used for legitimate program development.

● 100% Ethically source coded. Written in plain JavaScript - no frameworks or libraries.

● The JavaScript source code is open-source. It's not deliberately obfuscated. It's even commented, albeit gingerly.

● No APL font required. Characters are properly rendered.

 ESCAPE='HTML'
 ESCAPE='HTML'

Flexibility in simulating other vendors' versions and dialects

  • Match Data Representation codes and Name Classification codes used in MicroAPL's APLX vs. Dyalog. Custom configurable.
  • Match several APL versions' Atomic Vector. Custom mapping.
  • Match different versions of ASCII substitution digraphs and trigraphs for compatibility with ancient systems. Custom configurable.
  • Match custom characters & non-standard monadic/dyadic primitives pairing. The ELI dialect's character mapping is included (ELI is an alternate APL project by Wai-Mee Ching and Hanfeng Chen from 2011 to 2015). Possibly include J programming language and K programming language character mapping if possible.
  • Optional use of jot (AKA null) character as a separate separator. Similar to diamond character but statements are executed right-to-left.

What does / doesn't this implementation have?

This APL version does not have modern features such as nested arrays, complex numbers, defns, forks, trains. It wasn't written to compete with up-to-date commercial offerings. Otherwise it wouldn't be free. Instead it was written so that I can enjoy nostalgic programming of the mid '70s as in university on APL\360. Additionally it allows me to explore some ideas for APL extensions that I feel aren't too crazy.

This version does support - Extensions to some primitives. E.g. Dyadic Transpose, Ravel, Index-Of, Grade-Up/Down have additional functionality.

Dyadic Transpose extension

  • Reverse order along one or more axes. This facilitates rotating a matrix 90 or 180 degrees clockwise or counter-clockwise in one operation.
  • Extract major-diagonal, minor-diagonal, or any other diagonal.
  • Generate diagonal array.
  • Left argument is independent of Index Origin.

Ravel extension​

  • Ravels multiple axes together while delaminates planes / arrays along any axis.

Index-Of extension

  • Allows axis operator to specify along which axis to search.

Grade-Up / Grade-Down extension

  • Operates on any rank array - returns permutation vector of length first axis. This sorts elements, planes, arrays. Grade also works on character arrays.

    - new system functions and system commands

    - modern operators: Match, Tally, Reflex, Commute, Left, Right are implemented

    Some parameters and limits are configurable

    — A first in an APL implementation.

    • enable (case sensitive) or disable (case insensitive) lower case letter differentiation in function and variable names
    • array rank limit: default limit is set at 63 like the predecessor APL\360. This limit can be decrased to 15 axes (Dyalog APL 18.0) or increased to a maximum of 134217728 (2^27)
    • number of characters to differentiate function and variable names: default limit is set at 77 like the predecessor APL\360 but this limit can be increased or decreased to 3 (as in MCM/900 microcomputer from 1978)
    • array axis length limit: can be set to 2147483647 (2^31-1) as the APL\360's limit. It can be increased to as high as 9007199254740991 (2^53-1) or reduced to 255 (as in MCM/900 microcomputer from 1978)
    • - choice of internal array structure - JavaScript's regular vs. typed array to compare and benchmark performance

    Internal bytecode engine

    A user's APL source code is converted to a stream of bytecode tokens for preprocessing and fast execution. This happens automatically, in the background, and is of no consequence to the normal APL programmer.

    For advanced users this bytecode form can be viewed for any function or immediate-execution line. One can also write code using bytecode syntax. Such code can be mixed with APL expressions or can comprise entire functions.

    Revised 6 Jun 2021