Arno# - The cutting edge of developer waffle

Some random thoughts on software development

Ook# makes a monkey out of Obfuscated C

I was listening to the latest .NET Rocks! podcast this morning. The guest was Ted Neward, and he was discussing modern programming languages. He made the comment that there was even a .NET language written for the Librarian and other orangutans called Ook#. This sent me on a search of Google and a surreal voyage of discovery into languages that make the Obfuscated C Contest seem like a stroll in the park.

The C language is infamous for its support of really nasty unreadable code and the Obfuscated C Contest is a mostly annual competition to see who can come up with the “best” examples. One such is a less than conventional “Hello World” solution:

/*
* HELLO WORLD program
* by Jack Applin and Robert Heckendorn, 1985
* (Note: depends on being able to modify elements of argv[],
* which is not guaranteed by ANSI and often not possible.)
*/
main(v,c)char**c;{for(v[c++]="Hello, world!\n)";
(!!c)[*c]&&(v--||--c&&execlp(*c,*c,c!!c+!!c,!c));
**c=!c)write(!!*c,*c,!!**c);}

Some years back though, the language Brainfuck was created by Urban Müller that put such efforts to shame. The Brainfuck “Hello World” solution is:

>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++
[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.

The line breaks are just for neatness on this blog BTW. They are entirely optional within the language and have no significance. The entire language has just eight operators and cannot be expanded:

>    Increment the pointer
<    Decrement the pointer
+    Increment the value at the pointer
-    Decrement the value at the pointer
.    Write the value at the pointer to standard output
,    Read a value from standard input and store it at the pointer
[    If the value at the pointer is zero, jump past the matching ]
]    Jump to the matching [

These eight commands were then translated into Orangutan to give the following eight commands that make up the Ook! programming language:

Ook. Ook? Increment the pointer
Ook? Ook. Decrement the pointer
Ook. Ook. Increment the value at the pointer
Ook! Ook! Decrement the value at the pointer
Ook! Ook. Write the value at the pointer to standard output
Ook. Ook! Read a value from standard input and store it at the pointer
Ook! Ook? If the value at the pointer is zero, jump past matching Ook? Ook!
Ook? Ook! Jump to the matching Ook! Ook?

A “typical” example is a program that prints “Ook!”, and it looks like this:

Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
Ook? Ook. Ook! Ook! Ook! Ook. Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook! Ook. Ook! Ook!
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook! Ook? Ook! Ook! Ook? Ook! Ook. Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook!
Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook.
Ook! Ook? Ook! Ook! Ook? Ook!

Both Brainfuck and Ook! have been converted to .NET languages (Brainfuck.NET and Ook# respectively) by Lawrence Pit. You can download the source code for the compilers, along with some examples, from here.


Share This Post...

1 Comment so far

  1. V_RocKs April 25th, 2008 18:49

    Beautiful!

    I cannot wait to write something in Ook!

Leave a reply

Close