Hello World in APL
Your first APL program - the classic Hello World example with Docker setup
Every programming journey starts with Hello World. In APL, this is remarkably simple - in fact, it’s one of the easiest Hello World programs you’ll ever write.
The Code
Create a file named hello.apl:
| |
That’s it - just the string and an exit command. In APL, a string literal evaluates to itself and is automatically displayed. The )OFF command tells the interpreter to exit cleanly.
Understanding the Code
'Hello, World!'- A character vector (string) enclosed in single quotes- APL automatically displays the result of any expression
)OFF- A system command that cleanly exits the interpreter- No
printstatement, nomainfunction, no boilerplate
This illustrates APL’s philosophy: minimize ceremony and let you express your intent directly.
Running with Docker
The easiest way to run APL without installing anything locally:
| |
Command Line Options Explained
--silent- Suppress the welcome banner--noColor- Disable terminal color codes--noCIN- Don’t echo input (cleaner output for scripts)-f hello.apl- Read APL expressions from the file
Running Locally
If you have GNU APL installed:
| |
Installing GNU APL
macOS (Homebrew):
| |
Ubuntu/Debian:
| |
From source: Visit GNU APL for source code and build instructions.
Expected Output
Hello, World!
Interactive APL
APL is particularly powerful in interactive mode. Start an APL session:
| |
Then type expressions and see immediate results:
| |
The six-space indent is APL’s convention for showing user input, with results appearing without indent.
To exit, type )OFF (APL system commands start with ) ).
Going Beyond Hello World
APL’s power becomes apparent with array operations. Even in a “Hello World” tutorial, we can glimpse this:
| |
The single character ⌽ (reverse) flips the entire string. No loops, no indexing, no strlen() - just express what you want.
| |
The reshape operator ⍴ transforms our string into a 3x3 matrix.
A Note on APL Characters
You might wonder how to type symbols like ⍴ or ⌽. Modern APL systems provide several methods:
- Keyboard layouts - Special APL keyboard mappings
- Prefix keys - Type a prefix then a letter (e.g.,
`thenrfor⍴) - Tab completion - Type
rhothen Tab to get⍴ - Copy/paste - From documentation or the APL Wiki
For scripts like our Hello World, you only need standard ASCII characters.
Key Concepts
- No boilerplate - APL needs no imports, main functions, or print statements
- Everything is an expression - Even
'Hello, World!'evaluates and displays - Arrays are fundamental - A string is a character vector (1D array)
- Operators work on whole arrays - No explicit iteration needed
- Right-to-left evaluation - Expressions evaluate from right to left
Historical Note
When APL first ran on IBM mainframes in 1966, getting “Hello, World!” to display required:
- Special APL terminals with custom keyboards
- Time-sharing system access
- Significant computing resources
Today, a Docker command gives you the same experience Kenneth Iverson’s team created nearly 60 years ago.
Next Steps
Continue to Variables and Data Types to learn about APL’s array-oriented data model.
Running Today
All examples can be run using Docker:
docker pull juergensauermann/gnu-apl-1.8:latest