Beginner

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:

1
2
'Hello, World!'
)OFF

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 print statement, no main function, 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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create the source file
cat > hello.apl << 'EOF'
'Hello, World!'
)OFF
EOF

# Pull the GNU APL image
docker pull juergensauermann/gnu-apl-1.8

# Run the program
docker run --rm -v $(pwd):/app -w /app juergensauermann/gnu-apl-1.8 apl --silent --noColor --noCIN -f hello.apl

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:

1
2
# Run the script
apl --silent -f hello.apl

Installing GNU APL

macOS (Homebrew):

1
brew install gnu-apl

Ubuntu/Debian:

1
sudo apt install apl

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:

1
docker run --rm -it juergensauermann/gnu-apl-1.8 apl

Then type expressions and see immediate results:

1
2
3
4
5
6
      'Hello, World!'
Hello, World!
      2 + 2
4
      10
1 2 3 4 5 6 7 8 9 10

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:

1
2
      'Hello, World!'
!dlroW ,olleH

The single character (reverse) flips the entire string. No loops, no indexing, no strlen() - just express what you want.

1
2
3
      3 3'Hello,Wor'
Hello,
Wor

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:

  1. Keyboard layouts - Special APL keyboard mappings
  2. Prefix keys - Type a prefix then a letter (e.g., ` then r for )
  3. Tab completion - Type rho then Tab to get
  4. Copy/paste - From documentation or the APL Wiki

For scripts like our Hello World, you only need standard ASCII characters.

Key Concepts

  1. No boilerplate - APL needs no imports, main functions, or print statements
  2. Everything is an expression - Even 'Hello, World!' evaluates and displays
  3. Arrays are fundamental - A string is a character vector (1D array)
  4. Operators work on whole arrays - No explicit iteration needed
  5. 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
Last updated: