By any measure, there is an enormous number of programming languages. Some lists contain hundreds, while the Historical Encyclopedia of Programming Languages lists just under 9,000. You’ve probably only used a handful, and you might not be too surprised to discover that many of the rest are obscure, archaic, and just plain bizarre.
Find out quite how strange programming can get, from languages full of brackets, to those that interpret color or even code you cannot see at all!
Lisp, in which everything is a list
Lisp is an old language, possibly the second-oldest still in use today. It first appeared in 1960. The language’s name stands for “list processing,” but a common alternative, taking aim at the language’s unique syntax, is “lots of irritating superfluous parentheses.” It…
By any measure, there is an enormous number of programming languages. Some lists contain hundreds, while the Historical Encyclopedia of Programming Languages lists just under 9,000. You’ve probably only used a handful, and you might not be too surprised to discover that many of the rest are obscure, archaic, and just plain bizarre.
Find out quite how strange programming can get, from languages full of brackets, to those that interpret color or even code you cannot see at all!
Lisp, in which everything is a list
Lisp is an old language, possibly the second-oldest still in use today. It first appeared in 1960. The language’s name stands for “list processing,” but a common alternative, taking aim at the language’s unique syntax, is “lots of irritating superfluous parentheses.” It’s easy to see how it gained this name:
(defun factorial (n)
(if (zerop n) 1
(* n (factorial (1-n)))))
That function computes the factorial of a number, using recursion to do so. Recursion is a fundamental concept of the language, along with other powerful features such as dynamic typing and higher-order functions.
Perhaps the most mind-blowing thing about Lisp is its distinction between code and data: there isn’t one. Everything is an s-expression, which makes Lisp’s syntax remarkably frugal. As a result, many Lisp fans call it the only truly beautiful language and, once you get your head around the concept, it’s hard to disagree.
Lisp has undergone many revisions and spawned plenty of variants since its debut. One of the most successful is Emacs Lisp, which drives the flexible Linux text editor of the same name, and enables it to be incredibly configurable and extensible. The other high-profile use of Lisp is Arc, a dialect that powers the Hacker News website.
Prolog, the forerunner of AI coding
Prolog (translated as “programming in logic”) is the last serious language on this list, included because of its unusual paradigm and status as the original AI language. Prolog uses a declarative style, where programs describe the structure and logic of a task, rather than the process of how to accomplish it. Prolog does the rest, taking these rules and producing programs that use them.
This approach enables a particular type of programming, focused more on logic and natural language than control flow and algorithms. A Prolog program consists of facts like:
child(john,sue).
And rules, like:
parent(Y,X) :- child(X,Y).
These make up a knowledge base which you can then interrogate with queries like:
?- parent(sue,john).
This should return true to indicate that, yes, sue is the parent of john. Of course, such a trivial example isn’t very enlightening, but a more complex program with hundreds of thousands of rules and facts can draw far more interesting conclusions.
Prolog is particularly suited to solving logic puzzles like the Towers of Hanoi or the classic river crossing puzzle with a wolf, goat, and cabbage. It’s another example of a language that is difficult to get your head around; once you do, though, it’s easy to recognize its beauty and influence.
Befunge, the language with two-dimensional source code
Befunge is a classic example of an esoteric programming language; one that cares more about its artful abuse of language design than its practicality. Using these languages is a challenge, and they still require a combination of logical thought and creative interpretation. But, ultimately, they introduce a light-hearted touch to the normally serious world of programming.
Source code is line-oriented in many languages, and a rare few—like Python—care about which columns parts of your code are in, too. But Befunge takes this to the extreme: your code is individual characters, laid out in a grid:
0"!dlroW ,olleH"v
> , v
| : <
@
The program above prints “Hello, World!” by adding each character to the stack, then looping to print them out. The @ symbol near the bottom right of the program is the “end” command, to terminate execution of the program.
Befunge supports 26 different commands which cover arithmetic, control flow, i/o, and manipulation of a global stack, the singular data structure. It uses characters that look like arrows to control program flow, so this befunge program is an infinite loop:
>v
^<
You can use postfix notation to manipulate the stack; the . command outputs the value at the top. This program outputs 12:
48+.@
There are commands to move in a random direction, read from standard input, and duplicate the top of the stack. There’s also the wonderfully-specific “vertical if” operator!
The promise of graphical, or visual, programming veers in and out of fashion, with languages like Scratch aimed at the educational market. If one ever finds success, it may owe it all to Befunge, the language that essentially uses the most basic form of graphical display: ASCII art.
Piet, whose programs are abstract works of art
Piet Mondrian’s paintings that combined black grid lines with block primary colors are among the most iconic of 20th-century art. The Piet language takes inspiration from them, producing beautiful source code with absolutely no resemblance to what it actually does:
While this example doesn’t quite imitate Mondrian’s style, a Piet program can do so, with a bit of work:
Behind the scenes, Piet is a bit like Befunge, with blocks of color representing movement in 2D space within the program. Each specific command is defined not by a particular color, but by the transition from one color to the next, according to the change in its hue and lightness. Needless to say, Piet is not an easy language to program in, but it is said that true art requires a form of suffering.
Whitespace, because it makes you feel like a spy
What do you think the following program does?
Let’s make it a bit easier: how about the same thing with all text selected?
OK, that’s still pretty difficult to decode, but don’t blame yourself: this is the weird world of Whitespace, a language whose programs consist entirely of space, tab, and linefeed characters. You should probably learn how to show non-printing characters in your editor before you go anywhere near this one.
Use the :set list command in Vim to show whitespace characters and make sure your editor doesn’t strip trailing white space when you save your Whitespace files. Or just stay well away from Whitespace.
Apart from the idiosyncratic syntax, Whitespace shares a lot with other esoteric languages: it uses a stack, supports a limited set of operations, and recognizes just integer and character data types.
Whitespace ignores all non-space characters, but it depends on the characters that most other languages ignore, so a Whitespace program can be embedded in the source of a totally different language. If you wanted, you could smuggle a Whitespace program inside another. Even some of your existing programs could also be valid Whitespace code!
Shakespeare, a language with programs that could have been written by the bard
Hark h’re, useth this language and thy source shall beest as quaint as if ’t did spring f’rth from the bard’s pen.
In other words, Shakespeare is a programming language with source code that looks like Shakespeare wrote it. That sounds unlikely, I know, so here’s an example of a program that outputs “HI”:
Shakespeare achieves much of what it does by giving plenty of freedom to the programmer, so that they can write in a pseudo-Shakespearean language. In the example here, variables—Hamlet and Juliet—are declared with “Enter.” The phrase the Juliet speaks, beginning “Thou art,” is a computation based on the negativity of the adjectives and their number. “Speak your mind” is one way to output a value; in this case, the “H” in “HI.”
Like most esoteric languages, Shakespeare is hardly intended to be practical. But it’s a magnificent demonstration of just how varied programming languages can be, and just how imaginative some language designers can be, too.
JSF**k, a naughty language that works in any web browser
This is by far the rudest of any programming language here, but only because we left a couple of others off this list! JSFuck continues a tradition of expletives in esoteric language names that began with the original, Brainfuck, in 1993.
The JS version is notable because it’s a subset of JavaScript, so you can actually run it in a web browser. Why you would want to is another matter.
JSFuck is really an encoder, converting any reasonable JavaScript program into an unfathomable mess of code that only uses the characters [, ], (, ), !, and +. It takes advantage of certain properties of the JavaScript language to carry out this miraculous transformation, but it does so with complete disregard for efficiency. In JSFuck, Hello World takes up 3,039 characters. I won’t include the full code, but here’s an excerpt for flavor:
JSFuck is ultimately a proof of concept, demonstrating that every JavaScript program in existence only actually needs six characters to run. JavaScript is already responsible for a lot of website bloat, though, so you should probably avoid making it far, far worse.