Programming languages that melt your brain


In their day-to-day jobs, coders naturally focus on the more commonly used languages, such as C++, PHP and Python, but there are plenty of more left-field choices, such as Ruby and assembly, that are well worth learning to broaden your coding knowledge. Now we're going to have fun with some really esoteric languages, all of which are so fabulously crazy and entertaining to try that you'll look at programming in a completely different way.

Before continuing, you should know we'll be assuming you have a general programming background; that said, even if you've never written a line of code in your life, you'll still find some of the concepts here compellingly mind-twisting. You wouldn't want to use any of these languages to write any large, complicated applications, but you'll learn a lot about the makeup of programming languages. Plus C, for all its fiddliness, will seem like a gorgeous paradise once you've spent some time in these foreign lands...

Jump through Spaghetti hoops

Let's start with a nice, simple language: Spaghetti. When you're programming in Spaghetti, every line must end with the equivalent of a Basic GOTO - and you can't just GOTO the next line. In other words, no two consecutive lines of code are ever executed, because rational code flow is for sissies, right? Bring on the jumps!

Nigh-on every programming book in existence dissuades coders from using GOTO-like statements, instead recommending structured programming with proper loops and function calls. Spaghetti is designed to create cluttered code that jumps about, which is great if you're finding function calls and return()s too easy.

It is an interpreted language, and sets up a block of 8-bit memory on startup. When a program loads, the first 256 bytes of memory contain the numbers 1 to 255; there are also 26 variables, from a to z, which occupy memory locations 256 to 281. You can use the a and b registers together as a pointer to another location in memory.

For instance, setting both to 255 (FF in hexadecimal) means memory location 65565, or 64k. You can use * as shorthand to refer to the memory location to which a+b points.

On the instruction side, a? means "input a character and store it in the variable a", while ?a means "print the character stored in the variable a". Of course, you can change these variables to anything else in the a-z range. Every line of Spaghetti code must start with a line number, and end with another line number (as mentioned, it can't be the following line!). Programs begin execution at line 1, and terminate if they jump to line 0.

Comparisons are performed like this: a~b:5. This means "if a equals b, jump to line 5, otherwise jump to the line number at the end of the statement". Square brackets are used to denote code between the line numbers. So, 1[a~b:3]4 means "line 1: if a equals b, jump to line 3; otherwise jump to line 4".

Let's look at some Spaghetti code in action:


Clear as mud, eh? It actually makes sense when your mind is in Spaghetti mode. This program simply prints out characters you type on the keyboard until you press Enter, at which point it exits.

So, the Spaghetti interpreter starts executing code at line 1, which says "get a character from the keyboard and store it into the x variable". The 2 at the end means "jump to line 2" - but of course, line 2 can't follow line 1 directly, so it's above the first line!

When we jump to line 2, at the top, we check to see if the x variable (the entered character) is 13: a newline character, generated by the Enter key. If it is, we jump to line 0, which tells Spaghetti that we want to exit, if you remember. If it's not 13, we jump to line 3, which outputs the character in x and jumps back to line 2.

You'll probably want to read through that again; it's baffling, but once you work it out you'll get a strange satisfaction from wrapping your grey matter around such a weird concept. We've all seen dodgy Basic programs that haphazardly leap around the code like a Ritalin-craving gibbon, but after writing a few Spaghetti programs you'll be able to zip around messy source code and understand it perfectly. Er, if you're still remotely sane, that is.

Here Come's trouble

Whereas Spaghetti enforces the use of a GOTO after every line, Come Here, our next language, has COME FROM. This command is pretty much self-explanatory: where COME FROM 30 appears in the code, for example, the Come Here language interpreter executes code following the COME FROM after it has executed line 30. This means you're never sure how the program flow will unfurl unless you've read the entire body of code.

Here's an infinite loop program in Come Here, which prints out the string 'Developers' endlessly - just like a virtual Steve Ballmer:

10 TELL "Developers" NEXT

(Note that Come Here is case-sensitive.) First, Come Here executes line 10, which prints 'Developers' to the screen with the TELL command. NEXT, at the end, indicates the end of the command. The Come Here interpreter then jumps to the COME FROM 10 line (because line 10 has just been executed), which positions execution just before line 10, thereby executing it over and over.

Not all lines must have line numbers; they're more like labels for positions in the code. Now take a look at the following, which prints out 'Wowzers' ten times.

10 CALL 10 counter
COME FROM 10 + SGN counter
TELL "Wowzers" NEXT
11 CALL counter - 1 counter

On the first line, 10, we use CALL to assign the number 10 to a new variable, counter. The following COME FROM line means execution comes to here when line 10 + SGN counter is executed - 'SGN counter' meaning 1 if counter is a positive number (it means sign).

So, it comes from line 11 if the counter variable is a positive number, and line 11 decrements the value of counter by 1. In summary: line 10 sets up the variable, the TELL prints out 'Wowzers', line 11 decrements the variable and Come Here jumps up to the COME FROM lines while counter holds a positive number. Easy. no?

Befunge befuddlement

As strange as Come Here is, it still adheres to the tried-and-tested tradition of line numbers and statements on separate lines. But look at any source code file, and chances are you'll see a lot of whitespace (short lines, spaces, empty lines and so on). Why not make more use of this space?

After all, a standard Unix text terminal is 80x25 characters in size, so there's a lot more you can cram into this space if you keep things tight.

Befunge was designed by Chris Pressey in 1993, in an attempt to make a language that was difficult to compile. Instead of having lines of code, Befunge programs operate in a two-dimensional grid, and the program flow can move in any direction. Befunge is stack-based - you may already know about the 'stack' concept if you've programmed before, but if not, here's a primer for you.

A stack is a block of memory of arbitrary size, which has not only a position but an order. If you drop something into the top, it'll be the first thing you pull out. So if you put the numbers 3, 7, and 15 on to the stack, when you retrieve them you'll get 15, 7, and 3 in that order (last in first out, or LIFO).

It's a useful temporary holding ground, and given that Befunge doesn't have variables, you need to use the stack for any kind of data manipulation. In Befunge, program flow is defined by ^ (up), v (down), < (left) and > (right). If the interpreter comes across a number or letter, it puts it on the stack.

The comma (,) command outputs the value on the stack, and you can perform arithmetic on two numbers in the stack with +, -, / and * (add, subtract, divide and multiply). Here's a Hello World program in Befunge:

>                             v
v , , , , , " H e l l o "     <
> 4 8 * ,   	                v
v , , , , , , " W o r l d ! " <
> 2 5 * , @

Let's go through this. The program always begins execution in the top-left corner, and we tell Befunge to start moving right with the > command. The interpreter moves along over the spaces until it hits the v on the right-hand side, which tells it to go down. Then it hits <, to go left, and the main body of code begins.

You can see the Hello string: we step through that backwards, pushing the letters of Hello on to the stack in reverse order (elloH). Then we terminate that string with a " and move on to the , comma commands, which mean "pull data off the stack and print it". Still following?

We've pushed the 'elloH' characters on to the stack, and now we pull them off the stack. Because the stack is last-in first-out, we print the characters in reverse order - Hello - using the five print (,) commands.

After the printing, the v command says "go down", and > says "go right". We then push the numbers 4 and 8 on to the stack, multiply them with *, and print the result with ,. Now, 4 times 8 equals 32, which is the space character in ASCII, so we're printing a space. Execution moves through the empty spaces until the end of the line, at which point it goes down, then left, and then prints World! using the same method as Hello above.

Finally, we push 2 and 5 on to the stack and multiply them to get 10 and print it with , (10 being a newline). Then the Befunge interpreter hits the @ command, which simply terminates the program. What do you mean, complicated?

There's lots more to Befunge. You can get input from a user with the & and ~ commands (for numbers and letters respectively), which are pushed on to the stack. Or you can swap the top two numbers on the stack with \, and skip a command with #.

If you want to make things really exciting, try the ? command, which tells Befunge to choose a random direction and start executing. So with a ? your program could suddenly start moving left, or downwards - who knows? This is useful if you want to introduce some random elements to a program, although it becomes severely difficult to write programs that anyone can actually understand.

Combobulated C

One of the problems with C is that it doesn't enforce any particular coding style (unlike, say, Python). Sure, you can write clean, readable programs in C, but it's all too easy to mess up indents, whitespace, variable names, #defined macros and so forth. If you've ever had to work with someone else's C code, you may have stumbled across sections where you're left completely stumped, thinking, "What is the author doing here?"

And yet, in one coding circle, unreadable programming isn't just tolerated - it's encouraged! The International Obfuscated C Code Contest (IOCCC) is a yearly event when programmers submit wacky and near-undecipherable source code listings that look like they do one thing, but actually do another. Some developers create fantastic ASCII art-like programs you'd think would never compile, but somehow turn out to be programs.

Take the screenshot above right. Although this looks like a face, it's actually a valid C program, and when compiled it generates a different picture built up from the same source code! Visit and read through some of the other entries - even if you're a C guru, chances are you won't be able to fathom out what most of the programs do. Still, it's good fun compiling them to see what the output is...

Compile and run this program to generate, er, another picture!

Compile and run this program to generate, er, another picture!

Malbolge: the devil's PHP?

So far, so cuddly. Our next foray into the world of barmy coding is headed for darker things; specifically, a language called Malbolge. This is the single most difficult programming language in the history of existence, and its name is taken from Dante's Inferno, where Malebolge is the eighth circle of hell.

Legend has it that if you master Malbolge, you'll be able to levitate three feet above the ground, change the weather with a waft of your hand and always lay your hand on your car keys. In fact, we'll give £100 to anyone who can write a Malbolge clone of the Emacs psychotherapist Eliza (m-x-doctor).

Why are we making such a bold offer? Well, after Malbolge was invented, it took two years for the first program to appear - and it wasn't even written by a human! Malbolge is so horrendously, viciously complicated that anything above simple phrase printing is aeons away from us human beings, and even computer-generated Malbolge programs can't do much more. It's bad. It's ultra, super, mondo, ninja bad.

This is a computer-generated Malbolge program for the 99 Bottles of Bear song. Fear it.

This is a computer-generated Malbolge program for the 99 Bottles of Bear song. Fear it.

The Malbolge interpreter, at a basic level, works like a trinary CPU. If you've programmed in assembler you'll know binary (base 2), and most languages cater for hexadecimal (base 16). But trinary, base 3, is absurdly awkward to work with - so it's a perfect starting point for Malbolge. Think of trinary counting: 0, 1, 2, 10, 11, 12, 20, 21, 22, 100... Expressed as a noise, it's "ugh".

But that's probably the easiest part. Malbolge has three registers (a bit like variables) called A, C and D. A is the accumulator, which stores data manipulation results, while C and D store memory locations for code and data respectively. Note that C and D are incremented after each command. You can access 59,049 memory locations, each of which can contain a ten-digit trinary number.

Malbolge has eight instructions, covering jumping to a different part of the code, trinary digit rotation, keyboard input and output, and ending. There's also a 'crazy' instruction, which uses a table to determine a value from two input numbers - the Malbolge interpreter uses this to fill memory not initially used by your program, based on the initial parts of your program.

When Malbolge executes an instruction, it takes the value in the C register (let's say 4), adds its position in the code to it (let's say 390), then subtracts 94 repeatedly until the result is less than 94. The final number tells Malbolge the type of instruction to execute. After an instruction is executed, its location in memory is encrypted using a number-replacement lookup table, so you can't just jump back there again.

That's as much as we can describe without the magazine catching fire in your hands - for more devilry, see the Malbolge links in our Resources box, below. Let's finish this section with a Hello World program, which pretty much sums it all up:



You'll be pleased to learn that even in the esoteric programming world, there's some respite from this insanity. The coders behind the Nil language have taken a fresh approach to programming, putting design before hackery, just as so many developers have advocated.

We've all read about how high-level languages such as C# eliminate the tedious chores of coding and let us focus on what a program actually does - and the Nil team have got that down to a fine art.

Nil also brings many other benefits to the programming world, such as much-reduced object code size, simple debugging and complete portability between different machines. It's one of the few programming languages to promise all these useful features and actually deliver them - and you can't ask for more than that!

The language accepts source code in many formats, so consider the following:

for(b = 1; bytes < c_byte; b++) {
	if(!(bh[b] = sb_getblk(s, ++cur_index)))
		goto block_release;
	bytes += msBlk->devblksize;

As you can see, this snippet of code involves loops and comparisons. How do you optimise it? Well, the Nil compiler uses 'atomisation' to split up the code into a bunch of words, making it easier to parse and optimise.

Then Nil translates each atom; because it takes a nihilistic approach, it can determine that the ultimate result of each atomic operation is essentially a nop machine code instruction, and therefore performs the replacements as necessary.

Finally, through its 'peephole optimiser', Nil can determine that a series of nop instructions can be condensed into a single nop, saving space and execution time. Now, almost every mainstream CPU around understands the nop instruction - it simply means 'no operation', or 'do nothing' for a few clock cycles. So the Nil-compiled version of the above codeblock is:


Because, of course, everything is pointless, according to nihilists. Why get the CPU to calculate a Fourier transform, when it could just chill out while you have a cup of tea?

Nothing to see here

We couldn't have a feature on esoteric languages without a quick mention of Whitespace. This is probably the craziest language we know, simply because its instructions are made up of spaces, tabs and newlines - characters that aren't visible on the screen. In other words, a Whitespace program is not directly visible; you have to open it in a text editor, preferably one with syntax highlighting to show the various blank characters in different colours.

Despite this readability limitation, Whitespace is still very much a full programming language. Commands are built up of whitespace characters: for example, a tab, two spaces and a tab is a subtraction command. Whitespaces make heavy use of a stack (see the Befunge section) and you can even add labels to your code to create subroutines. Modular programming is vital on large projects, and Whitespace doesn't miss out!

Consider the following block of code:

Here we add together two numbers, and store the result in memory. Whitespace's developers stress that the language has many applications in the field of security: for instance, should anyone come across a Whitespace code listing printout, they won't be able to see how it works to find potential vulnerabilities.

Similarly, hard-copy listings of Whitespace code are also good for the environment, as they save on ink usage. If post-structuralists hacked on Linux, this is the language they'd use.

You can 'see' Whitespace programs if you use a syntax-highlighting editor.

You can 'see' Whitespace programs if you use a syntax-highlighting editor.

Finishing off

So there we have it: the strangest programming languages ever conceived, perhaps not destined for greatness but fascinating all the same. Spaghetti is entertaining to play around with, just for the feeling of deliberately making things complex, which changes your mindset when you do some real programming.

And now that you have read all about the brain-frazzling Malbolge, you'll go back to plain old C with renewed vigour - like a sprinter with a tyre behind their back, you'll suddenly feel a lot lighter when released from it.

See our Resources box, below, for more information on these languages, and have fun trying out programs with them. Do let us know how you get on!


The site has a great wiki all about esoteric programming languages.

The site has a great wiki all about esoteric programming languages.

First published in Linux Format

First published in Linux Format magazine

You should follow us on or Twitter

Your comments

SDL is a programming language?

Funny, I always thought SDL to be a library...

cool post!

that was a cool read, thanks!


Unlike the languages here, Snobol was a real language for string processing, originally developed at Bell Labs. Here's a Snobol3 program for replacing every occurrence of FOO by BAR in an input file.


S(xxx) means branch to xxx if the operation (read a line from SYStem Peripheral Input Tape, or pattern match) succeeded, and F(xxx) means branch if it failed.

Snobol3 was succeeded by the much more ornate and powerful Snobol4 which had the same amount of branchiness. Needless to say, pasta lovers found the spaghetti in Snobol programs delectable.

i need books on php

pls i need books on php iam a programer in php language
my email adress is

Ops ! god what I read!

Ops ! god what I read!


your whitespace contains no chars!

i dun beleive they r exists

mind boggling stuff...


Taaaaaame. Way too tame. You have Come Here but don't even mention the much more bizarre progenitor of its main feature, Intercal? Befunge is great, but I sort of feel like Piet makes a better demonstration (who _doesn't_ want to demonstrate their program via a colourful bitmap?). Also, Chef. There's something so amusing about code written in Chef.

Not including Brainfuck, I understand, however. Tarpits are pretty old-hat these days, and I think they covered that category pretty well with whitespace (while showing off another neat bit).

real hardest programming language

not really a language but it kind of is.

open an empty .exe file in notepad and code from there.
makes no sense but some have done things by copying blocks of text from compiled programs.


I was expecting a mention of Lolcode, but most of these are in a different league.


How do you even make this list without brainfuck? I kind of want to learn malbolge now. lol.


If you don't even know Javascript then good luck with malbolge lol.

Why Does My Fireplace Smoke

Should you be looking to get a new relationship wall-mounted electrical hearth then you've got select one out of the available choices all on your own. In order to think of trustworthiness and useful potential then you would wish to choose of a basic flame electrical fire. They appear consequently realistic occasionally, that folks not have an inclination to realize that what they are staring in, basically it is not a genuine fire but a new holographic model. <a href="">Why Does My Fireplace Smoke</a>

Today is the first day of

Today is the first day of the rest of your life.
visit : <a href="">Kollagen Intensiv Trial</a>

Web site

Questo might essere un remarkably extraordinary impressive instrument che oneself stai providing e far too your self basically present e assente value-totalmente free!! Io identical towards studying web-siti che impression il sure!
<a href="">Web site</a>

Great article! I have

Great article! I have actually frequently thought of this very topic. You've definitely put a tremendous quantity of thought and study into developing this substantial post. You presented and suggested many elements I had actually ruled out. Well done. Do you intend on writing a follow-up? Janine, <a href="">healthy diet for diabetics</a> researcher

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

We can't accept links (unless you obfuscate them). You also need to negotiate the following CAPTCHA...

Username:   Password:
Create Account | About TuxRadar