[Editorial note: I have often stated that one must consider the intended audience in any piece of writing. I've also been known to point out that code is a form of writing and that the principal audience, in this case, is not the compiler. This article demonstrates just how much the style of code can be affected by inverting the usual assumption that the intent is to communicate what the code does to your audience. - Alan]
Four years ago I collaborated on the THADGAVIN [thadgavin] entry to the International Obfuscated C Code Contest [ioccc]. It won an award (Most Portable Output), but it was a behemoth, only just scraping inside the maximum size limit for the contest. Much of its complexity was inherent in the algorithm, the obfuscation was a straightforward refactoring, and the reason for the award was mostly due to the use of a cross platform library. In conclusion, while it was a winner, in the end I was not happy with the "art" of the code.
The following year I wrote another entry. This time I wanted to do something functional and minimalist, something with a strong theme, and something self-referential. I had striven, and in my opinion failed, to make the 2000 entry a visual as well as an intellectual appeal. I wanted to do the same again in 2001, but again I wanted to be minimalist. I wanted to create a piece of code that could be considered to be "art" on multiple levels. So here, for your pleasure, I present my short (untitled) program:
/*(c) 2001 Thad */ #include<string.h> #include <stdio.h> #define abc stdout int main(int a,ch\ ar*b){char*c="??=" "??(??/??/??)??'{" "??!??>??-";while( !((a=fgetc(stdin)) ==EOF))fputc((b=s\ trchr(c,a))?fputc( fputc(077,abc),abc ),"=(/)'<!>""-"??( b-c??):a, abc);??>
I encourage you to study it. Try to work out what it does without compiling and running it.
Now, assuming you've worked out what it does, can you work out how many sins are committed in these 14 short lines of code? How many good practice guidelines are broken?
[thadgavin] http://thad.notagoth.org/thadgavin/
[ioccc] http://www.ioccc.org/
Overload Journal #65 - Feb 2005 + Programming Topics
Browse in : |
All
> Journals
> Overload
> 65
(9)
All > Topics > Programming (877) Any of these categories - All of these categories |