Esoteric programming languages: a systematic approach
A surprising number of programming languages were created to accomplish unusual tasks that have nothing to do with programming. These are commonly called esoteric. Today, we«re going to paint a general overview of the esolang landscape, and try to figure out why people are continuing to create them.
Markus Spiske PD
Esoteric languages combine mainstream programming conventions and things you wouldn«t typically associate with computer science — like modern art and humour. According to Federico Tomasetti, a professional language engineer, the purpose of esoteric languages is to upset people«s expectations, and force IT professionals to think critically of the tools they«re used to. This effect can be achieved by a number of things: from simply being weird to elaborately provoking an emotional response.
Let«s take a look at the kinds of challenges esoteric languages pose, and try to categorize them.
Criterion 1: Turing-completeness
The most obvious way to categorize esoteric languages is by their Turing-completeness — ability to express algebraic functions. A great example of a Turing-complete esoteric language is INTERCAL, described by its maintainer Eric S. Raymond as «fundamentally unlike any existing language». Raymond claims that his creation is capable of «reducing strong men to tears (of laughter)», and is of interest to self-professed «technomasochists». Despite the seeming lack of seriousness, INTERCAL is not only viable, but even influential. Its thought-provoking qualities inspired an entire generation of esoteric programming languages.
On the other side of the spectrum are Turing-incomplete languages, like HQ9+. This joke language was designed to only perform four tasks, commonly tackled by novice programmers. The H keyword performs the «Hello World» routine. The Q (quine) keyword outputs the program«s source code. The + keyword increases the accumulator variable by one, and the 9 keyword outputs the lyrics to the song »99 Bottles of Beer».
Turing-completeness, or lack thereof, is not an indicator of usability in and of itself. Turing-complete esoteric languages frequently become so-called «Turing tarpits» thanks to their dysfunctional syntax. Theoretically, they are capable of completing a wide range of tasks, but, in practice, they make writing complicated code next to impossible. To understand how hard even the simplest tasks can get, let«s look at a simple «Hello, world» script, written in Brainfuck — one of the most infamous esoteric languages in existence:
+++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++.+++++++++++++++++ ++++++++++++.+++++++..+++.------------------- --------------------------------------------- ---------------.+++++++++++++++++++++++++++++ ++++++++++++++++++++++++++.++++++++++++++++++ ++++++.+++.------.--------.------------------ --------------------------------------------- ----.-----------------------.
Criterion 2: Purpose
Federico Tomasetti groups esoteric languages by purpose, such as:
1. Languages that were designed to perform a specific task. These might be quite niche, but nonetheless valuable. For example, the Turing-complete Thue meta-language, named after the famous Norwegian mathematician, is used to define and recognize Type-0 languages from the Chomsky grammar hierarchy.
2. Black box languages. Some languages are made to be intentionally unintelligible — to mislead and confuse outsiders. Such is Malbolge, the language named after the 8th circle of hell in Dante«s Inferno — home to fraudsters and speculators. The quine program in Malbolge is 59 thousand characters long, and was first successfully created only 14 years into the language«s existence. To an uninitiated reader, its source code looks like a random set of letters and special characters.
But not all black box languages are that cruel. Case in point: the BANCStar programming language. While unintelligible to outsiders, BANCStar was developed for commercial purposes and has seen actual use. Despite its complicated syntax, which only consists of digits and commas, it was used to create a total of around 1350 programs. The intentional unintelligibility of the source code served to protect sensitive financial information the language was used to process.
3. Proof-of-concept languages. Some things have to be done just to show that you can. Programming languages are no exception. Such is the Befunge family of multi-dimensional languages, created to play around with execution order and push compilers to their limits.
Criterion 3: Inspiration source
Esoteric programming languages often reflect personal interests of their creators.
1. Film. One of the most popular esoteric languages inspired by film is var«aq. This Klingon-influenced esolang was introduced by Brian Connors, a hardcore «Star Trek» fan. According to the creator, the name «var«aq» doesn«t mean anything in Klingon, but sounds like it might belong to a famous mathematician (like Pascal). The syntax of the language, Brian claims, inspires a Klingon-like approach to programming. Other film-inspired esolangs include ArnoldC — a programming language with keywords borrowed from Arnold Schwarzenegger quotes, and Groot, a language where all the commands are variations of the «I am groot» sentence.
2. Literature . A number of esoteric programming languages are inspired by literature. For example, Shakespeare — the language created by Karl Hasselström and Jon Åslund while they were studying syntax analysis. They were vaguely familiar with other esoteric languages and decided to build one of their own as a research project. The end result was capable of transforming any algorithm into a short Shakespearean-style play, with dramatic characters exchanging snide remarks. Every program is structured like an actual stage play: it is divided into multiple acts and scenes. Here«s an excerpt from the first act of a simple «Hello World» script, guaranteed to make Shakespeare roll in his grave:
The Infamous Hello World Program.
Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.
Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
[Enter Hamlet and Romeo]
You lying stupid fatherless big smelly half-witted coward!
You are as stupid as the difference between a handsome rich brave
hero and thyself! Speak your mind!
You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!
You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.
Speak your mind!
3. Visual art . Perhaps, the most famous esoteric language inspired by visual art is Piet, named after the Dutch abstract painter Piet Mondrian. It does away with written language, and requires programmers to imagine their creations as abstract pixel art. The functionality of the program is determined by the shapes and colours of the programmer«s drawing. The end result, in many cases, resembles the works of the language«s namesake.
Other art-inspired esoteric languages include Matisse (a color-coded Brainfuck modification) and Magritte, the language with only one possible program. «The Treachery of Images», Rene Magritte«s famous painting of a pipe, features the phrase «Ceci n’est pas une pipe» («This is not a pipe»). The only statement you can write using Magritte-the language is the similarly brain-wrecking «This is not a program». Of course, it«s not: we«re looking at the source code.
Criterion 4: Comedic value
Some esoteric languages have no use apart from their comedic value. These can be separated into a category of their own. The esolang wiki lists more than 130 such languages. Examples include: the cheese-inspired Cheese family of languages (complete with Cheese, Cheese+ and Cheese++), and TURKEY BOMB, the world«s first programming language that is also a drinking game.
But it doesn«t have to be one way or the other — most esoteric languages do not take themselves seriously, regardless of their usefulness. For example, INTERCAL«s documentation is riddled with jokes. The introduction to the manual humorously notes that «any resemblance of the programming language portrayed here to other programming languages, living or dead, is purely coincidental.»
Esoteric languages were meant to destroy boxes and shatter preconceptions, so it«s no wonder that they«re so hard to categorize. In the second part of this essay, we«re going to delve even further into the esolang scene, and talk about the users of these bizarre languages.
Inside ITMO University: