Arcane Programming Languages

Arcane Programming: Whitespace

Justin Ohms
3 min readMay 25, 2023

Whitespace is a fascinating esoteric language that flips traditional programming on its head, inverting the convention of meaningful characters and passive whitespace.

“Hello World” in Whitespace. Note: the text other than spaces or tabs is all just comments.

The History of Whitespace

Like many languages that fall into this category, Whitespace was created as something of a joke and more out of a love for programming languages than for any practical purpose.

Whitespace was created by Edwin Brady and Chris Morris at the University of Durham in 2002, earning a review on Slashdot on the release day, April Fool’s Day, 2003. Brady and Morris also created the Kaya and Idris languages. The language’s name signifies its principal concept, which is its interpretation of whitespace characters. In contrast to most other programming languages, Whitespace pays no heed to non-whitespace characters, only spaces, tabs, and linefeeds carry any meaning.

This characteristic permits a Whitespace program to be concealed within the whitespace characters of a program written in another language. This makes it a perfect candidate for writing a polyglot — a text that can be interpreted in multiple programming languages. (Of course, just remember to turn off your linter.) Interestingly, the concept of using whitespace characters as operators had been humorously proposed five years earlier by Bjarne Stroustrup.

Syntax and Architecture

Whitespace is Turing complete, it runs on a virtual machine and is an imperative stack-based language like Forth and PostScript. Programmers can push arbitrary-width integers (it doesn’t currently support floating point numbers) onto the stack and also interact with the heap as a constant store for data structures and variables.

In terms of syntax, commands are constituted from sequences of spaces, tab stops, and line feeds, while all other characters are ignored, thereby serving as comments. The code is constructed as an Instruction Modification Parameter (IMP) followed by the operation. Whitespace has an array of IMPs for various operations, ranging from stack manipulation and arithmetic to heap access, flow control, and I/O.

In Whitespace, numbers are represented by spaces (for 0) and tabs (for 1), terminated by a line feed. The initial space/tab indicates the number’s sign: a space for positive, and a tab for negative. The remainder spaces and tabs represent the binary number.

Labels, on the other hand, are simple, line-feed-terminated lists of spaces and tabs. The language has a single global namespace, necessitating all labels to be unique.

The display of Whitespace source code can get complicated and it might vary across different browsers or text editors due to the variable spacing produced by the tab character. This depends on its position in the text relative to the next horizontal tab stop, and sometimes, the software may replace tab characters with the corresponding variable number of space characters. It is best to use a text editor with visibility for non-printable characters turned on.

The Future of Whitespace

Unfortunately, the original primary site for Whitespace at the University of Durham was taken down some time ago. You can still access it on the WayBackMachine; however, work continues on GitHub with over 50 different projects, including interpreters in over a half-dozen languages, assemblers, compilers, docker containers, and purpose-built IDEs.

This article is just part of an ongoing series on Arcane and Esoteric programming languages. Follow me if you want to see more.

I write on a wide variety of topics including programming, travel, politics, books, and AI. You can see all of my stories on Medium here.

If you like my stories on Medium, you can subscribe here to get them directly in your inbox. That way you’ll never miss one!

You can also support other authors and me by joining the Medium community. Sign up for a membership using this link. For only $5 a month, you get unlimited access to all the stories on Medium and I also get a small commission at no extra cost to you.

(Some of the links in my articles may be affiliate links for which I might receive a small commission.)

--

--

No responses yet