Todays programming language insanity is a real winner. It’s a language called SNUSP. You can find the language specification [here][snuspspec], a [compiler][snuspcomp], and [an interpreter embedded in a web page][snuspinterp]. It’s sort of like a cross between [Befunge][befunge] and [Brainfuck][brainfuck], except that it also allows subroutines. (And in a variant, *threads*!) The real beauty of SNUSP is its beauty: that is, programs in SNUSP are actually really quite pretty, and watching them run can be positively entrancing.
SNUSP keeps its data on a tape, like Brainfuck. The basic instructions are very Brainfuck like:
1. “<" move the data tape pointer one cell to the left.
2. ">” move the data tape pointer one cell to the right.
3. “+” add one to the value in the current data tape cell.
4. “” subtract one from the value of the current data tape cell.
5. “,” read a byte from stdin to the current tape cell.
6. “.” write a byte from the current tape cell to stdout.
7. “!” skip the next instruction.
8. “?” skip the next instruction if the current tape cell contains zero.
Then there’s the twodimensional control flow. There aren’t many instructions here.
1. “/” bounce the current control flow direction as if the “/” were a mirror: if the program is flowing up, switch to right; if it’s flowing down, switch to left; if it’s flowing left, switch to down; and if its flowing right, switch to up.
2. “\” bounce the other way; also just like a mirror.
3. “=” noop for drawing a path flowing left/right.
4. “” noop for drawing a path flowing up/down.
So far, we’ve pretty much got a straightforward mix between Brainfuck and Befunge. Here’s where it becomes particularly twisted. It also has two more
instructions for handling subroutines. There’s a call stack which records pairs of location and direction, and the two instructions work with that:
1. “@” means push the current program location and the current direction onto the stack.
2. “#” means pop the top of the stack, set the location and direction, and *skip* one cell. If there is nothing on the stack, then exit (end program).
Finally, the program execution starts out wherever there is a “$”, moving to the right.
So, for example, here’s a program that reads a number and then prints it out twice:
/==!/===.===#
 
$====,===@/==@/====#
So, it starts at the “$” flowing right. Then gets to the “,”, and reads a value
into the current tape cell. It hits the first “@”, records the location and direction on the stack. Then it hits the “/” mirror, and goes up until it hits the “/” mirror, and turns right. It gets to the “!” and skips over the “/” mirror, then the “.” prints, and the “#” pops the stack. So it returns to the
first “@”, skips over the “/” mirror, and gets to the second “@”, which pushes the stack, etc.
Here’s a simple subroutine for adding 48 to a cell:
=++++++++++++++++++++++++++++++++++++++++++++++++#
Or a slight variant:
/=+++++++++++++++++++++++++\
 #+++++++++++++++++++++++/

$
Or (copying from the language manual), how about this one? This one starts to give you an idea of what I like about this bugger; the programs just *look* cool. Writing a program in SNUSP can be as much art as it is programming.
#/\/\
$===!\++++\
/++++/
/=\++++\
\!\/\/\/
One last +48 subroutine,
123 4
/=@@@+@+++++#

$
This last one is very clever, so I’ll walk through it. The “1234″ on the top are comments; any character that isn’t an instruction is ignored. They’re there to label things for me to explain.
The program goes to @1. It pushes the loc/dir on the stack. Then it gets to @2, pushed again. (So now the stack is “@1right,@2right”). Then @3, push (stack=”@1right,@2right,@3right”). Then add one to the cell. Push again (stack=@1right,@2right,@3right,@4right”). Then 5 “+”s, so add 5 to the cell. So we’ve added 6. Then we hit “#”, so pop, return to @4, skip one cell. So 4+s get executed. So we’ve added 10. Then pop again (so stack is “@1right,@2right”), return to @3, skip one instruction. So we’re back to @4; push (stack=@1right,@2right,@4right). Add five (we’re up to “+15″), and pop the stack, which brings us back to @4 again, and skip one cell, so now add another 4 (+19). Pop (stack=@1right), and we’re at @2. Skip one instruction, so we jump over @3. Then add one (+20), and repeat what happened before when we first got to “@4″, adding another 9 (+29). Pop again (so stack is empty), skip one instruction, so we’re at @3. Skip, push, repeat from @4 (+38). Pop back to @2, skip @3, add one (+39), push @4, repeat the same thing from @4 again (+48).
Here’s a real beauty: Multiplication, with documentation. If you look at it carefully, it’s actually reasonably clear how it works! Given this instruction set, that’s *truly* an amazing feat.
read two characters ,>,==\ * /=================== ATOI ———\
convert to integers /=/@
multiply @ \=!\=========/ // /++++++++++/ \\
convert back !/@!\============/ \++++++++++\ //
and print the result \/ \.# * /++++++++++/ \#
/====================/ * \++++++++#

 /<+>\ #/?=<<<<\!>>>>\ />>+<+<\
 #\?===/! BMOV1 =====\ \>>>>+/ // /======== BSPL2 !\======?/#
 />+<\ /============== FMOV4 =/ // /<<+>+>\
 #\?===/! FMOV1 ==================\ /====/ /====== FSPL2 !\======?/#
 /============================/
 * * **  *  * * * * * * **  * * * /+<\
 * />@/<@/>>@/>>===\ /====>>\@<\@<\ * /==== ADD2 !\>=?/<#
\===== MUL2 =?/>@\==<#<<<==\ \!\<<<<@\>>>>?/\ * // /\
* \\ \/@==============
* * * \\* * * *  * * * *  * * * * *// //
\\  \==========/ //
\======!\=======================/
Want to see more true brilliance? How about integer square root? Written to look almost like the square root radical?
/>!/?\>=!/?\>!/=======?\<<<#
 \/<=\/ \>>>+<<</
sqrt=>+<=!/?!/>?\+>?/\
\\!=<<+>/<<+>/
\===<++/
One last example: one of the most pathological functions ever, Ackermann's function. This was designed by a mathematician trying to prove that there were programs that didn't require the full power of a turing machine, but that were more complicated than primitive recursive functions. The definition of the function is:
A(x,y) = y + 1 if x = 0
or A(x1,1) if x > 0 and y = 0
or A(x1,A(x,y1)) if x > 0 and y > 0
The value of Ackerman’s function grows like nothing else. A(4, 2) is about 2×10^{19728}.
Here’s Ackerman’s in SNUSP:
/==!/==atoi=@@@@—–#
 
  /=========\!==\!====\ ** recursion **
$,@/>,@/==ack=!\?\<+#    A(0,j) > j+1
j i \@/#   A(i,0) > A(i1,1)
\@\>@\>@/@\<@/# A(i,j) > A(i1,A(i,j1))
# #   
/<<+>>\!=/ \=======@\>>>@\<<#
(a > 0) ? ?   
\>>+<</!==========/  
# #  
 
#/?========\!==/ \==!/=======?\#
\>>+>+<<>>+<<</
[snuspspec]: http://www.deepwood.net/~drlion/snusp/snusp1.0specwd1.pdf
[snuspcomp]: http://www.baumanfamily.com/john/esoteric.html
[snupsinterp]: http://www.quirkster.com/snusp/snuspjs.html
[brainfuck]: http://scienceblogs.com/goodmath/2006/07/gmbm_friday_pathological_progr.php
[befunge]: http://scienceblogs.com/goodmath/2006/07/friday_pathological_programmin.php