Esoteric programming language
An esoteric programming language is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language, or as a joke. The use of distinguishes these languages from programming languages that working developers use to write software. Usually, an esolang's creators do not intend the language to be used for mainstream programming, although some esoteric features, such as visuospatial syntax, have inspired practical applications in the arts. Such languages are often popular among hackers and hobbyists.
Usability is rarely a goal for esoteric programming language designers—often the design leads to quite the opposite. Their usual aim is to remove or replace conventional language features while still maintaining a language that is Turing-complete, or even one for which the computational class is unknown.
History
The earliest, and still the canonical example of an esoteric language was INTERCAL, designed in 1972 by Don Woods and James M. Lyon, with the stated intention of being unlike any other programming language the authors were familiar with. It parodied elements of established programming languages of the day, such as Fortran, COBOL, and assembly language.For many years INTERCAL was represented only by paper copies of the INTERCAL manual. The language's revival in 1990 as an implementation in C under Unix stimulated a wave of interest in the intentional design of esoteric computer languages.
In 1993, Wouter van Oortmerssen created FALSE, a small stack-oriented programming language, with syntax designed to make the code inherently obfuscated, confusing, and unreadable. It also has a compiler of only 1024 bytes. This inspired Urban Müller to create an even smaller language, the now-infamous brainfuck, which consists of only eight recognized characters. Along with Chris Pressey's Befunge, brainfuck is now one of the best-supported esoteric programming languages. These are canonical examples of minimal Turing tarpits and needlessly obfuscated language features. Brainfuck is related to the P′′ family of Turing machines.
Examples
Befunge
allows the instruction pointer to roam in multiple dimensions through the code. For example, the following program displays "Hello World" by pushing the characters in reverse order onto the stack, then printing the characters in a loop which circulates clockwise through the instructions>
, :
, v
, _
, ,
, and ^
."dlroW olleH">:v
^,_@
Binary lambda calculus
is designed from an algorithmic information theory perspective to allow for the densest possible code with the most minimal means, featuring a 29 byte self interpreter, a 21 byte prime number sieve, and a 112 byte Brainfuck interpreter.Brainfuck
is designed for extreme minimalism and leads to obfuscated code, with programs containing only eight distinct characters. The following program outputs "Hello World!":++++++++++>++.>+.+++++++
..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.
FRACTRAN
A FRACTRAN program is an ordered list of positive fractions together with an initial positive integer input. The program is run by multiplying the integer by the first fraction in the list for which is an integer. The integer is then replaced by and the rule is repeated. If no fraction in the list produces an integer when multiplied by then the program halts. FRACTRAN was invented by mathematician John Conway.GolfScript
Programs in GolfScript consist of lists of items, each of which is pushed onto the stack as it is encountered with the exception of variables which have code blocks as their value, in which case the code is executed.INTERCAL
, short for "Compiler Language With No Pronounceable Acronym", was created in 1972 as a parody to satirize aspects of the various programming languages at the time.JSFuck
is an esoteric programming style of JavaScript, where code is written using only six characters:
,
, !
, and +
. Unlike Brainfuck, which requires its own compiler or interpreter, JSFuck is valid JavaScript code, meaning JSFuck programs can be run in any web browser or engine that interprets JavaScript.
LOLCODE
is designed to resemble the speech of lolcats. The following is the "hello World" example:
HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE
LOLCODE is frequently criticized for not being very esoteric, but rather being an ordinary procedural language with an unusual vocabulary.
Malbolge
was designed to be the most difficult and esoteric programming language. Among other features, code is self-modifying by design and the effect of an instruction depends on its address in memory.ModiScript
is an esoteric programming language that entirely consists of quotes from Indian Prime Minister Narendra Modi's speeches. The language follows many of his ideologies such as the "No import rule", in which importation of code is not allowed, consistent with his "Make in India" campaign.The following code prints "Mandir Wahin Banayenge":
mitrooon
UP "BJP governed state hai"
SP "opposition me hai"
agar ye sach hai
bhaiyo aur behno "Mandir wahin banayenge"
nahi toh
bhaiyo aur behno "Abhi decision nahi liya gaya hai"
achhe din aa gaye
Piet
Piet is a language designed by David Morgan-Mar, whose programs are bitmaps that look like abstract art. The compilation is guided by a "pointer" that moves around the image, from one continuous coloured region to the next. Procedures are carried through when the pointer exits a region.There are 20 colours for which behaviour is specified: 18 "colourful" colours, which are ordered by a 6-step hue cycle and a 3-step brightness cycle; and black and white which are not ordered. When exiting a "colourful" colour and entering another one, the performed procedure is determined by the number of steps of change in hue and brightness. Black cannot be entered; when the pointer tries to enter a black region, the rules of choosing the next block are changed instead. If all possible rules are tried, the program terminates. Regions outside the borders of the image are also treated as black. White does not perform operations, but allows the pointer to "pass through". The behaviour of colours other than the 20 specified is left to the compiler or interpreter.
Variables are stored in memory as signed integers in a single stack. Most specified procedures deal with operations on that stack, others with input/output and with the rules by which the compilation pointer moves.
Piet was named after the Dutch painter Piet Mondrian. The originally intended name, Mondrian, was already taken.
Pikachu
Pikachu is a programming language created by Nilabhro Datta with the stated purpose of being "designed specifically to be usable by Pikachus". Pikachu recognizes only 3 syntax elements,pi
, pika
and pikachu
.Pikachu makes use of 2 stacks,
pi pikachu
and pika pikachu
that users are able to use and manipulate. Pikachu has also been shown to be Turing complete.Shakespeare
is designed to make programs look like Shakespearean plays. For example, the following statement declares a point in the program which can be reached via a GOTO-type statement:Act I: Hamlet's insults and flattery.