Strange Computer Languages: A Hacker’s Field Guide
Posted by admin on
Why do we build radios or clocks when you can buy them? Why do we make LEDs blink for no apparent purpose? Why do we try to squeeze one extra frame out of our video cards? We don’t know why, but we do. That might be the same attitude most people would have when learning about esolangs — esoteric programming languages — we don’t know why people create them or use them, but they do.
We aren’t talking about mainstream languages that annoy people like Lisp, Forth, or VBA. We aren’t talking about older languages that seem cryptic today like APL or Prolog. We are talking about languages that are made to be… well… strange.
INTERCAL
We have to start at the beginning. INTERCAL. This was started as a joke in 1972 and the acronym is purportedly for Compiler Language With No Pronounceable Acronym. There was no actual implementation, though, until around 1990. Now there are two: C-INTERCAL and CLC-INTERCAL.
Since INTERCAL is a parody, it makes some very odd choices. For example, bitwise operators like AND operate with two arguments, but one of the arguments is reversed. That is, the top bit of one operand matches the bottom bit of the second operand. In a nod to social convention, there is a modifier known as PLEASE that you should sometimes use when, for example, reading data as in “PLEASE READ IN.” If you don’t use it often enough, the compile will fail warning you that the program is insufficiently polite. However, if you use it too often, you’ll also get an error that your program is excessively polite.
Originally, the implementation used EBCDIC, so it uses some characters that don’t appear on conventional 7-bit ASCII systems. This forced some character substitutions and now, with Unicode, some versions will allow the old-style characters if you prefer them. The INTERCAL manual renames nearly all the special characters for further confusion. A single quote is a “spark” and the equal sign is a “half-mesh”. Only the ampersand remains unscathed.
Want to know more? Be careful what you wish for.
FALSE and Brainf**k
Fast forward to 1993 to the birth of FALSE, a stack language made to be unreadable. As a consolation, the compiler only needed 1,024 bytes. This inspired an even more minimal language, Brainf**k. There are only eight characters needed in a BF program.
Brainf**k has spawned a lot of similar languages like Befunge and JSF**k. If you’ve heard of only one language in this post, it was probably this one.
What does it look like? From the esoteric language Wiki:
++++++++[>++++[>++>+++>+++>+<<<+>+>->>+[>.>---.+++++++..+++.>>.>+.>++.
That’s Hello World, by the way!
Binary Combinatory Logic and Unlambda
We once knew a college professor who used to say “maximize the boolean variable” when he meant “set the bit to 1.” We think he’d like BCL. If you want to express true in BCL, you write K(KK). False? K(K(SK)). It gets worse from there. Here’s XOR: S(S(S(SS)(S(S(SK)))S))K.
However, this is binary, so S is really 01 and K is 00 and the left parenthesis is a single 1. Super strange and apparently has some application in some theoretical math studies.
There are several versions of this, all slightly different. Unlambda, for example, uses a lot of different characters. Here’s a “cat” program in Unlambda:
```s`d`@|i`ci
Whitespace
Most programming languages don’t care about white space and you can use it liberally or not. That is, in C you can write:
x=10*2;
or:
x = 10
*
2;
The compiler doesn’t care. Python is different. Indentation levels matter. Whitespace takes that to the extreme. The entire program is written in tab, space, and linefeed, and everything is ignored. That may seem odd, but interestingly it allows you to hide a program inside another program — as long as it isn’t a Python program.
The first whitespace character tells you what the next one means. For example, all flow control sequences start with a linefeed. Stack manipulation starts with a space. A tab and a linefeed introduce I/O operations. A tab and a space is for math and two tabs manage heap access.
Even numbers are in binary where a space is positive, a tab is negative. After that, a space is 0 and a tab is 1.
LOLCODE
While whitespace is possibly even less comprehensible than Brainf**k, some languages try to imitate particular readable things. Case in point: LOLCODE which has programs that match up with LOLCAT meme captions. Apparently, LOLCATs were the main reason the Internet was invented, after all.
Why do we assume cats talk like this? We aren’t sure, but we have a feeling the narrative inside a real cat’s brain is more like, “It is certainly hard to find good servants these days!” The ancient Egyptians worshipped cats and cats have not forgotten this.
Here’s a program to count to 10:
HAI 1.3 IM IN YR loop UPPIN YR var TIL BOTH SAEM var AN 10 VISIBLE SMOOSH var AN " " MKAY! IM OUTTA YR loop KTHXBYE
Rockstar
Maybe you aren’t a fan of LOLCATs but you like rock music. Well, then, Rockstar is the programming language for you. Variable names can be almost anything and data have types like “mysterious.”
We assume that to be a good coder in this language you need to grow your hair out, mumble, and own at least one article of clothing made of spandex. Come to think of it, that describes quite a few programmers we know.
Among the clever things it does, numbers are expressed in the length of words, and many programming constructs have “obvious” English-language correlates. So “Hate is water” assigns 5 to the variable “Hate”.
Here’s Fizbuzz written in Rockstar:
Midnight takes your heart and your soul While your heart is as high as your soul Put your heart without your soul into your heart Give back your heart Desire is a lovestruck ladykiller My world is nothing Fire is ice Hate is water Until my world is Desire, Build my world up If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing Shout "FizzBuzz!" Take it to the top If Midnight taking my world, Fire is nothing Shout "Fizz!" Take it to the top If Midnight taking my world, Hate is nothing Say "Buzz!" Take it to the top Whisper my world
Shakespeare
If rock music is too pedestrian for you, there’s always SPL, the Shakespeare Programming Language. Like the bard, the programming language isn’t known for its economy of words.
Numbers are especially tricky in SPL. Nouns have a value of -1 or 1 depending on how nice they are (e.g., trees and flowers are 1 while pigs are -1). Adjectives multiply by 2. So “lying stupid fatherless big smelly half-witted coward” is -1 (coward) * 2 * 2 * 2 * 2 * 2 * 2 = -64.
Around the Hackaday watercooler, we’ve thought about writing a new version of this language where all programs are in the form of a conversation between the bard and Sir Francis Bacon. We’ll call it Shake ‘n Bake.
Here’s just part of the 89-line Hello World script — er — program:
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] Hamlet: 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! [Exit Romeo] Scene II: The praising of Juliet. [Enter Juliet] Hamlet: Thou art as sweet as the sum of the sum of Romeo and his horse and his black cat! Speak thy mind!
Malbolge
Malbolge was designed to be difficult to use. Reportedly, the first program to print hello world required another computer program to search all the possible programs until it found the right sequence. If you don’t recognize the reference, Malbolge is a misspelling of Malebolge, the 8th circle of hell in Dante’s Inferno.
Malbolge uses a base-three virtual machine. There are only a few instructions including rotate right and the “crazy” operation that changes bits in a way defined in a table and — as far as we can tell — has no relation to any normal math operation, and is essentially encryption. Malbolge is so awful that there are some attempts like Dis have been made to be “slightly less evil.”
Piet
Have you ever noticed how in science fiction movies, aliens almost always communicate using some kind of sound we can hear? They either speak English or they speak something that sounds like Andy Kaufmann doing a character. You rarely see aliens that flash lights, emit pheromones, or beam low-frequency radio waves to communicate. All the languages on this list use characters of some sort either as numbers, symbols, or words. Except for Piet. Piet programs are abstract art of the sort created by Piet Mondrian.
A single unit of code is a codel and blocks of codels have the same color. The “program counter” can move in two dimensions, of course. If Piet interpreted, for example, red as add and green as jump then it would be another form of symbols. But that’s not how it works. Instead, the interpreter looks at the change in hue and intensity between colors. So one step in hue and no change in lightness is an add operation. But if the color changes darker, that’s subtract. Here’s hello world in Piet. Don’t ask us to explain it!
Why? Why?
It isn’t worth wondering why people create or use these languages. Why do people buy pet rocks? Why do people collect postage stamps? They just do. Still, learning a little about one of these quirky languages can push you out of your comfort zone and that’s not always a bad thing. Besides, a lot of people would say writing assembly for a PIC or AVR is only slightly less cryptic than Malbolge and many Hackaday readers do that.
As for us, we’ll stick with more practical programming languages. Forth seems cryptic, but is great and can create very legible programs in the hands of an expert. We do, however, occasionally dive into these languages for fun.