Est. 2003 Advanced

Whitespace

An esoteric programming language where only whitespace characters (space, tab, and linefeed) are significant, while all other characters are ignored as comments.

Created by Edwin Brady, Chris Morris

Paradigm Esoteric, Imperative, Stack-based
Typing None (operates on arbitrary-precision integers)
First Appeared 2003
Latest Version 0.3 (2003)

Whitespace is an esoteric programming language created in 2003 by Edwin Brady and Chris Morris at the University of Durham. Its unique characteristic is that only whitespace characters—spaces, tabs, and linefeeds—are meaningful. All other characters are completely ignored, treated as comments.

History & Origins

Whitespace was released on April 1st, 2003, and announced on Slashdot. Most readers assumed it was an April Fool’s joke, but the language was (and is) completely real and functional. The timing was deliberate—what better day to release a language that inverts the normal rules of programming?

The Creators

Edwin Brady and Chris Morris, both at the University of Durham, created Whitespace. Brady is perhaps better known for creating the Idris programming language, a dependently-typed functional language. The same mind that gave us cutting-edge type theory also gave us a language of invisible instructions.

Why Whitespace?

The language is a commentary on how most programming languages treat whitespace: as insignificant formatting that helps humans read code. Whitespace flips this convention entirely—the characters humans can see are meaningless, and the invisible characters carry all the meaning.

How It Works

The Three Characters

Whitespace uses exactly three characters:

CharacterASCII CodeCommon Notation
Space32[Space] or S
Tab9[Tab] or T
Line Feed10[LF] or L

Everything else in a Whitespace program is ignored.

Stack-Based Architecture

Like Forth and Brainfuck, Whitespace is stack-based. It operates on a stack of arbitrary-precision integers, meaning there’s no limit to how large numbers can grow (within memory constraints).

The language also provides a heap for random-access storage, making it more powerful than pure stack-based languages.

Instruction Modification Parameter (IMP)

Instructions in Whitespace begin with an Instruction Modification Parameter (IMP) that determines the category of the operation:

IMPCategory
[Space]Stack Manipulation
[Tab][Space]Arithmetic
[Tab][Tab]Heap Access
[Tab][LF]I/O
[LF]Flow Control

Commands

Stack Manipulation (IMP: [Space])

CommandParametersDescription
[Space]NumberPush the number onto the stack
[LF][Space]-Duplicate the top of stack
[Tab][Space]NumberCopy the nth item to the top
[LF][Tab]-Swap the top two items
[Tab][LF]NumberSlide n items off the stack, keeping the top
[LF][LF]-Discard the top of stack

Arithmetic (IMP: [Tab][Space])

CommandDescription
[Space][Space]Addition
[Space][Tab]Subtraction
[Space][LF]Multiplication
[Tab][Space]Integer Division
[Tab][Tab]Modulo

Heap Access (IMP: [Tab][Tab])

CommandDescription
[Space]Store: pop value and address, store value at address
[Tab]Retrieve: pop address, push value at that address

I/O (IMP: [Tab][LF])

CommandDescription
[Space][Space]Output the top of stack as a character
[Space][Tab]Output the top of stack as a number
[Tab][Space]Read a character, store at address on stack top
[Tab][Tab]Read a number, store at address on stack top

Flow Control (IMP: [LF])

CommandParametersDescription
[Space][Space]LabelMark a location in the program
[Space][Tab]LabelCall a subroutine
[Space][LF]LabelJump unconditionally to a label
[Tab][Space]LabelJump to label if top of stack is zero
[Tab][Tab]LabelJump to label if top of stack is negative
[Tab][LF]-Return from subroutine
[LF][LF]-End the program

Number Encoding

Numbers are encoded in binary using space for 0 and tab for 1, prefixed with a sign bit (space for positive, tab for negative) and terminated by a line feed.

For example, to push the number 72 (ASCII ‘H’):

  • Sign: [Space] (positive)
  • Binary: [Tab][Space][Space][Tab][Space][Space][Space] (1001000 = 72)
  • Terminator: [LF]

Label Encoding

Labels are encoded similarly to numbers but without a sign bit—just a sequence of spaces and tabs terminated by a line feed.

The Polyglot Potential

Because all visible characters are ignored, a Whitespace program can be embedded invisibly within:

  • Other programming language source code
  • Plain text documents
  • HTML/CSS files
  • Any text file with significant whitespace

This makes Whitespace popular for:

  • Steganography: Hiding programs in plain sight
  • Polyglots: Programs valid in multiple languages
  • Obfuscation challenges: Where finding the hidden program is part of the puzzle

File Extensions

Whitespace source files typically use:

  • .ws - Most common
  • .wspace - Alternative
  • .whitespace - Explicit

Running Whitespace

Various interpreters exist:

  • Haskell reference implementation - The original
  • Python implementations - Many available on GitHub
  • C implementations - For speed
  • Online interpreters - For experimentation

For this tutorial, we use the esolang/whitespace Docker image for consistent cross-platform execution.

Viewing Whitespace Code

Since the code is invisible, you need special tools to work with it:

  1. Hex editor: Shows the actual bytes (0x20, 0x09, 0x0A)
  2. cat -A (Unix): Shows tabs as ^I and marks line endings
  3. od -c: Shows all characters including whitespace
  4. Syntax highlighters: Some editors have Whitespace modes that colorize the invisible characters

A Word of Caution

Whitespace is intentionally unusual. It’s designed for:

  • Exploring the concept of significant whitespace
  • Steganography and polyglot programming
  • Programming challenges and puzzles
  • Having fun with conventions

It is not designed for:

  • Production code
  • Practical applications
  • Teaching beginners to program

Continue to the Hello World tutorial to write your first (invisible) Whitespace program.

Timeline

2003
Edwin Brady and Chris Morris create Whitespace at the University of Durham
2003
Released on April 1st, posted to Slashdot as an April Fool's joke (though it was real)
2003
Version 0.3 released, becoming the stable specification
2000s-Present
Numerous interpreters and compilers developed in various languages (Python, C, Java, Rust, etc.)
Present
Remains a popular esoteric language for steganography and programming challenges

Notable Uses & Legacy

Steganography

Embedding invisible programs within other text files or source code, since non-whitespace characters are ignored.

Polyglot Programming

Creating programs that are valid in multiple languages, with the Whitespace code hidden in the whitespace of other programs.

Programming Challenges

Used in CTF competitions and puzzle challenges due to its invisible nature.

Compiler/Interpreter Education

Writing a Whitespace interpreter is a common exercise for learning about parsing and stack machines.

Language Influence

Influenced By

Brainfuck Forth

Influenced

Other invisible character languages

Running Today

Run examples using the official Docker image:

docker pull esolang/whitespace

Example usage:

docker run --rm -v $(pwd):/code:ro esolang/whitespace whitespace /code/hello.ws

Topics Covered

Last updated: