Last updated: February 13, 2018
Meet Whitespace: The World’s Most Impractical Programming Language?
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Whitespace is an esoteric programming language developed by Edwin Brady and Chris Morris at the University of Durham, England. In Whitespace, only spaces, tabs and linefeeds have meaning, while all other non-whitespace characters are ignored by the interpreter.
If this sounds weird and impractical, yes it is! In fact, that’s the whole point of Whitespace.
Brady and Morris got the idea to create Whitespace during a conversation in a pub, in late 2002. Since most programming languages ignore whitespace characters, the developers considered this to be unfair to these members of the character set, and decided to create Whitespace. We should probably note that most programming languages are not designed in pubs, so this is just another factoid that makes Whitespace unique.
Whitespace was released on April 1st 2003, so at first it seemed like an overly elaborate April Fool’s Joke. However, the April 1 release date was purely coincidental. Actually, the release date turned out quite handy, as it attracted a lot of attention on Slashdot when it was officially announced.
Whitespace is an imperative, stack-based programming language supporting integers. Support for floating point numbers is not implemented. In its syntax, only whitespace characters – space, tab and line feed have meaning, all other characters are ignored. As a consequence, Whitespace programs can be contained within the whitespace characters of a program written in another language, or within a plain text file.
In theory, a programmer could write a novel around their Whitespace code – the code would still work, yet most people would only see the novel, not the underlying Whitespace code.
Being an esoteric programming language (esolang), Whitespace is created to test the limits of computer programming language design, and not intended to be used for mainstream programming. It is simply a proof of a concept, with very limited practical applications, since it’s hardly used in the real world.
However, as a tech demonstrator designed to prove that you could actually have a working programming language based on whitespace rather than characters, it definitely works. Unfortunately, Whitespace wasn’t designed for anything more than that. It was an elaborate tech demo, not a programming language designed for practical applications.
Commands in Whitespace, as well as the entire code, are composed out of sequences of spaces, tab stops and linefeeds. For example, tab-space-space-space performs arithmetic addition of the top two elements on the stack. Code is written in the form of an Instruction Modifier Parameter (IMP) followed by the operation. Whitespace has the following IMPs: “space” – stack manipulation, “tab-space” – arithmetic, “tab-tab” – heap access, “linefeed” – flow control, “tab-linefeed” – input/output.
Data is represented in a binary form, using spaces for 0 and tabs for 1, followed by a linefeed, for example space-space-space-tab-tab-space-linefeed is the binary number 000110, which is 6 in decimal.
The following example counts from 1 to 5 and prints out the numbers from 1 to 5, where “S” represents space, “T” – tab, and “L” – linefeed:
The output from the code above is:
How about writing Hello World in Whitespace? Well, that would require you to code pretty much every single letter and you’d end up with about 950 instances of space, tab and linefeed. It’s definitely not an example we can include in our introduction to Whitespace, but in case you’re interested, and you have too much spare time on your hands, you can check it out here.
There is next to no use in learning Whitespace, but if you like the concept and you would like to learn more about it, or try a few examples, check out the following resources:
- The official Whitespace website is offline, so your only option is to check out the Wayback Machine archived content with explanations, tutorials and examples of the Whitespace programming language in action.
- You can try a few examples using the Whitelips IDE Online Whitespace compiler, that loads the “Hello World” example by default. You will be surprised at how long the example is, because in Whitespace, you have to define each character one by one using ASCII codes.
As a programming language, Whitespace is as exotic as it gets, even by esoteric language standards.
While it’s not a programming language people actually use for anything productive, it’s a clever mental exercise and it serves as proof that you can turn almost anything into code, at least in theory.
Once you try it and figure out how it works, you’re more or less done with Whitespace, since you really can’t use it for anything serious. Well, at least not unless you have a lot of time to kill and nothing better to do.