IOCCC Accepting New, 'Improved' Entries
Rudolf writes: "The 16th International Obfuscated C Code Contest is open from now until 01 Dec 2001 23:59:59 UTC. Details are at the IOCCC web site. From the front page,
the contest goals are: -- To write the most Obscure/Obfuscated C program (within contest rules -- To show the importance of programming style, in an ironic way. -- To stress C compilers with unusual code. -- To illustrate some of the subtleties of the C language. -- To provide a safe forum for poor C code. :-)"
To stress C compilers with unusual code
Some compilers become stressed easier than others.
Anybody notice the 'A is for ASCII, B is for Byte' stuff on the winners index?
link
"Draco dormiens nunquam titillandus."
I once heard, it may be a rumour, but at least it's a nice story, that (once upon a time) russian coders liked to write code with obfuscation built in. They were so scared to loose their jobs that they wrote code only themselves could understand, using strange/misleading variable names, senseless loops or whatever. Can anyone confirm this? I think it's a nice technique ;-) Maybe the compiled code is even easier to understand...
This sig is stolen from someone who had a much better idea than I had.
Or would that be too easy?;)
My favorite isn't so much obfuscated code, but hair-brained.. I've actually seen this by paid contract programmers......
String getLetter( int index ){
String [] x = { "A", "B", "C", "D" };
for ( int i = 0; i < 4; i++ ){
if ( i == 0 && index ==0 )
return "A";
else if ( i == 1 && index == 1 )
return "B";
else if ( i == 2 && index == 2 )
return "C";
else if ( i ==3 && index == 3 )
return "D";
if ( i >= 4 )
break;
}
return null;
}
Are they getting paid by the line?
It's probably necessary to limit the contest to a specific language, but it would be cool to see a competition with other languages as well. Perhaps a limited set of "reasonable" languages (or everything will be written in esoteric (weird) languages (did anyone say Malbolge?).
I'd really like to see obfuscated/weird code in a language less "obfuscatable" than C (maybe Java or somethingorother?).
In that way, "obfuscation" can be more a matter of weird program flow and such, instead of confusing (but not very "interesting") a?b:c-statements (whatever they're called, I've forgotten it) and other C specialties.
Obfuscation is more of a challenge if you don't have as many weird operators and such do go with, and you have to fool people some other way.
Perhaps an Obfuscated Pseudo Code Contest?
There are 010 kinds of people. Those who understand octal, those who don't, and 06 other kinds of morons.
I've written Perl and then come back six months later and been unable to figure out what it was doing. Perl is not the world's first Write Only Language (That honor might go to APL though) but it's certainly one of the better ones.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
The highlight of the annual Computer Bowl occurred when
Bill Gates,
who was a judge, posed the following
question
to the contestants:
After a moment of silence, Jean-Louis Gassee (ex-honcho at Apple) hit his buzzer and answered:
Mr. Bill's expression was, in the words of one who was there, "classic."
Trolling using another account since 2005.
There already is one!
...
Also, if you go to Perl Monks, there are heaps of people submitting obfuscated Perl code for judgement
Cat got your tongue? (something important seems to be missing from your comment
Best Slashdot Co
Either the IOCCC has already been slashdotted or the obfuscated source of Apache is in recompilation.
void main(){
printf("hello world!");
}
If that's not obscure, what is?
~ now you know
Don't forget, there was once a day where everyone didn't have 1Ghz processors, 21" monitors, and graphical debuggers.
Yes C was written in one respect to save on key strokes, but that was when computers didn't have monitors - you punched keys (not so easy to press), and got your output on a teletype printer. God knows you wouldn't want to by typing Cobol programs this way.
My guess is that programmers probably took more time designing their program before they started keying it in. C, with short commands, and abbreviated syntax only made it easier to get your darn program into the computer.
My favourite obfuscation is this pi-program.
The only thing in main() is large drawing of a filled circle. And then it says
"If you want better accuracy, make a bigger drawing"!
-- A Mathematician is a machine for turning coffee into theorems. - Paul Erdös
In the early days of programming this was almost standard practice, EVERYWHERE!
In the early days, IBM used to have "aptitude tests" that asked candidates whether they liked the "puzzles", e. g., in the newspapers and gave tests to evaluate this kind of "skill".
It took only a short step for programmers to realize that all programs could be written as "puzzles". If weak management accepted this, then you have Microsoft!
Now you know why all those old, old programs look the way they do!
No, C is/was not designed to "save a few keystrokes here and there". It was designed to be able to be terse yes, and to not limit the programmer (Mr Programmer asks to do x and asserts: Yes, this is _really_ what I want to do), but it's got nothing to do with typing speed.
Often C allows the programmer to express things in a short (terse) form that are intrinsically "obvious".. if it's not, then it's obfusticated; which is allowed too... but it's not the compilers job to decide what humans can and can't easily read.
No need to, I have found a perfect auto obfuscater, it's called cat(1) ....
RFC1925
There already is one.
http://www.sysadminmag.com/tpj/obfuscated/
"You cannot find out which view is the right one by science in the ordinary sense." - C.S. Lewis on Intelligent Design
I saw some of the source code to Microsoft's ODBC drivers, years ago. I gave up trying to figure out their SQL parser when they referenced -5 from the start of an array. Scary stuff.
www.lucernesys.comHorizon: Calendar-based personal finance
int X,x[100];
for(X = 0; X < 100; ++X){
X[x] = X;
}
for(;X > 0; --X){
printf("%d\n", (int)(100 - X[x]));
}
10: PRINT "Everything old is new again."
20: GOTO 10
check out this
and look under the C link.
This is the 1990 winner. A complete basic interpreter. For fun I unobfuscated this code (Took a couple of hours). it's really a piece of art. several commands. Variables. Parentesis and operator precedence. Cool Stuff.
' !' );}d=B;while(*F=*s){*s=='"'&&j
* B){X'E':l=-1
) ,P [*d]=S():(*(q=Q(B,"TH"))=0,p
u ts (B+6):(p=B+5,printf("%d\n",S
#define O(b,f,u,s,c,a)b(){int o=f();switch(*p++){X u:_ o s b();X c:_ o a b();default:p--;_ o;}}
#define t(e,d,_,C)X e:f=fopen(B+d,_);C;fclose(f)
#define U(y,z)while(p=Q(s,y))*p++=z,*p=' '
#define N for(i=0;io&&!*z)_ x;}_ 0;}main(){m[11*R]="E";while(puts("Ok"),gets(B)
)switch(*B){X'R':C=E;l=1;for(i=0;i",'#');U("=",
++;if(j&1||!Q(" \t",F))*d++=*s;s++;}*d--=j=0;if(B[1]!='=')switch(
X'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B
=B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,p
()))X'G':p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 X'F':*(q=Q(B,"TO"))=0;p=B+5;P[i
=B[3]]=S();p=q+2;M[i]=S();L[i]=l X'N':++P[*d]',>)O(K,V,'$',=)
O(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p
All Perl programs are basically obfuscated, so a contest is not needed.
When compiled and run, it prints out the 12 days of Christmas.
12days.c
And this one is has very interesting source, I think it calculates pi.
pi.c
My beliefs do not require that you agree with them.
I'm a computer programmer, not an English major! If I wanted to write English in my programs, I'd use COBOL!
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
You should take a look at the Shakespeare Programming Language, or SPL for short. It combines the best features of BASIC, assembly language, and Hamlet. In SPL, every program is a play, and the plot closely follows the program execution. You can program SPL for a living during the day, then come home and read the source code as a good-night story.
How's that for obfuscation?
A few years back somebody submitted the definitive self-replicating (i.e. prints its own source code) program. It consisted of a 0-byte C file. The author pointed out that even though it's not technically a legal C program, most C compilers (including the one the IOCCC uses) will in fact accept it and proceed to spit out a binary that does nothing.
The most evil entry though has to be the Spinellis entry from 1988, which consists of the line #include "/dev/tty". This actually caused a change in the rules so that programs can't require user intervention to compile anymore, short of running make.
Not in my short experience. The Russians i work or worked with have high standards for readability. Sometimes weak knowledge of english causes misunderstandings.
Once upon a time and once upon an office?
It must have been tried somewhere, maybe in Russia. And then they start sweating to get the bugs out.
The best way to make the code hard to decipher is to put a bad programmer on it. Although, in lisp...
Anyone got a mirror site/link?
Brian
--
100% Linux Based Web Hosting
H4R3-br41N3D, not hare-brained, not hare-braned, not hare braned, not hair brained.....
No, C was designed to limit the number of keywords required. There's a huge difference. Compare C to pascal. C has less than a dozen keywords and Pascal has almost 100, but neither is more readable if used correctly.
Also, C was not popular until we already had video terminals - and then, C was the UNIX-head-only language until the 80's.
You're so incredibly misinformed about computer history.
Hands in my pocket
Whoops - my mistake... I'll learn to read eventually, I promise!
If you'd ever seen the works of art that come out of the Obfuscated Perl contests that already exist you wouldn't say it's easy. Some of the stuff those guys come up with blows your mind in terms of invention and thoughtfulness. Just because Perl has weird syntax to people brought up on C doesn't make it pre-obfuscated and doesn't reduce the genius behind some of the crazy code I've seen come out of those contests.
Go to perlmonks.org and search for 'obfuscated' or 'perl golf' and you'll see what I mean. The original Perl Golf game was to find a word in the dict file that had 10 non-repeating characters and the winner was a solution that was only 14 characters worth of code. Now that's cool.
At a previous employer, we had a home-grown database system (written in IBM mainframe assembler). We were a non-profit company, and perhaps because some of the development was paid for by the government, there was some stipulation that the source code back then had be made available to qualified parties.
Worried that we would lose our intellectual property, the company hired a consultant to determine the best way to obfuscate the code before sharing it. After looking over the code, the consultant noted that we didn't need to do a thing to it to prevent others from understanding it!
Ken (a 1997 winner of the IOCCC)
(We gotta keep up with the code bloat like everyone else
(why 521? Well 521 is prime and 2^521-1 is a Mersenne prime and I like primes
chongo (was here)
(boolean expression) ? TRUE : FALSE;
"Ken (a 1997 winner of the IOCCC)"
Do you point this accomplishment out to prospective employers? Do they view it as a positive thing? :)
No, that isn't what it was.
C was supposed to be a better (portable, mostly) assembly, a lot of its contracsts can be translated directly to proccessor instructions.
The most obvious thing is, of course, ++ and += type of thing.
You must also remember that C as we know it today (C99) isn't at all what K&R C was.
C actually got a lot of things from Pascal (function signatures, and variable types, frex) that made it a language much more suitable to write applications than it used to be. There was a reason why C was used to low level stuff up until the 90s, and why Pascal (or Borland's version of it) was so popular for so long.
As a note, Ada programmers have contests for *clear* code.
In a language that was designed to be as clear as possible.
--
Two witches watched two watches.
Which witch watched which watch?
Actually, outside of deliberately confusing syntax, the relitive terseness of a langue really doesn't matter.
:= x+1 or x := x+2
For example, is it more or less readable to have a
begin
do something
end
vs. a
{
do something
}
?
Both are equally readable, one just takes fewer keystrokes.
When you compare C to Pascal, you see how in every case, C is much more terse, but still, for the most part, readable.
And there are things like..
x++ or x += 2
instead of:
x
Granted, there are annoying idioms that hurt the readability of the code. The (a?b:c) construction sometimes falls into this range. Using x = (++a) + (b--) sort of idioms also falls into this range. But most of those are abuses of the language and not regularly intentional coding strategies.
Gentoo Sucks
I could really use an unobfuscater to translate all the code I write at 3:00am while on a Jolt/Vivarin high.
It would also come in handy when I have to look at the code the interns wrote.
Actually C is all about making the C compilier as simple as possible. For the most part, the terseness is a result of this.
However, the greatest and longest laugh at a IOCCC BOF occurred when I presented your 1998 Best abuse of the rules. For those you were not there, his entry consisted of a single, simple Un*x portable line of code:
That Truely twisted entry is listed in my top 10 all time best IOCCC progs.chongo (was here)
instead of:
x
In pascal, you use ':=' and not '=' to assign values, and thus reserve '=' for equality comparition instead of that horrible '=='. This, unfortunately is one of the things about C that Java should NOT have borrowed. On the other hand '=+' and '=-' are ok. 'a++' and 'b--' are also, but not when used in assignments:
String copying from 'The C programming language' by K&R:
while (*s++ = *t++);
This neat little piece of code copies the string t to s. Scary..
FYI: This year we are allowing use of OpenMotif which should improve things for folks writing new X-Windows progs.
chongo (was here)
Heck, that's not unique to Russians. It's alive and well in the West, that's fer damnsure.
Go to the Jargon File (www.jargon.org), and look up "job security".
You cannot apply a technological solution to a sociological problem. (Edwards' Law)
Over the years, gcc has survived the best. It has chucked core cookies on a few entries, but not nearly as often as some of the commercial C compilers.
If a winning entry does cause problems for somebody's C compiler, we usually file a bug report. They may not be pleased with the code sample, but that is the break;'s. :-)
p.s. The entry that broke causde the most problems on the most platforms was the 1988 Best of show. Not only did it crash a few C pre-processors, it cause one system to turn casters-up when it ran out of swap space!
chongo (was here)
I have often thought about that the := vs. = and == vs = issue.
:= be the assignment and then make == the equality comparison, to make things crystal clear.
And, really, either way you look at it, it's as orthogonal as possible.
For == to be comparison means that it is similar to !=. Both are nice two character operators, and also parallel =, etc. are the exceptions in this case. This also means that, with = be assignment, +=, -=, etc. are orthogonal.
:= is more mathematically correct, because assignment has little to do with equality, so that makes things more explicit. Then = is what it means, and is orthogonal with . However, then you have to make # the not equal operator if you want the not equals to be similar in form, or you have to use either or !=. This also means that the += operators should be +:= to be unambiguous.
The good thing, I suppose, would be to make
Java makes the = vs. == error harder to do by the simple requirement that an if () take a boolean value instead of an int or bool.
The best solution would be to switch to a unicode character set for programming, so that you could make everything perfectly regular and orthogonal. But that just plain sucks because you would need more keys on the keyboard or weird character combinations and the source would be a bitch to deal with.
Gentoo Sucks
Segfault had a classic article about the First Annual Readable Perl Contest about a year ago... :-)=
[TMB]
Perl takes me back, though.
Every time I look at someone else's perl, I expect a line to end with "NO CARRIER"...
-l
p.s. Speaking of twisted array references I like Korn's: 1987 Best One Liner:
Try to figure out what it does without compiling it first. Over the years I have not found very many people who could do it correctly the first time.
It compiles with out any special flags:
Hint: it does not work the same on a Microsoft based system. :-)
chongo (was here)
I give, I'll just have to try compiling it. I suspect it's using my favorite C trick, "there's no such thing as arrays". Arrays are just pointer arthimetic. But those type conversions and casts(?) make my head spin.
www.lucernesys.comHorizon: Calendar-based personal finance
Today I found this snippet of code:
bool func()
{
if (true)
return true;
else
return false;
}
(Well, the function once was useful and instead of completely erasing it, it was changed to this)
Actually that code does serve a purpose when programming on Windows/MFC/C++ systems. In MFC, TRUE is defined as the integer constant '1' and FALSE is defined as the integer constant '0'. Whereas the return from the boolean expression will either be the C++ boolean value 'true' or the C++ boolean value 'false'. And depending on the warning level of the compiler, it will complain/mention that you're converting a boolean to an integer, so adding the ? TRUE : FALSE will eliminate the warning.
Things you think are in the Constitution, but are not.
Are you sure? Here is what I get:
./1
host% uname -v
FreeBSD 4.4-RELEASE #0: Fri Sep 21 17:54:34 EEST 2001 root@host:/usr/src/sys/compile/HOST
host% echo 'main() { printf(&unix["\021%six\012\0"],(unix)["have"]+ "fun"-0x60);}' > 1.c
host% make 1
cc -O -pipe -march=pentiumpro 1.c -o 1
host%
unix
host%
So I guess it's not really a "C compiler, is it?
The reason for the silly ++ and -- operators is simply because of the lack of good optimizers long ago.
"*s++ = *t++" directly maps to a SINGLE instruction on many CPU architectures. eg: 'move (a0)+, (a1)+'
Those operators made it easier to make the compilers use the capabilities of the CPU.
Today, optimizing compilers can and do figure this out all on their own.
Number of keystrokes was not the issue. Too bad it has infected so many languages since. In fact, on some CPU's today just having the ++ and -- operators throws a monkey wrench into the optimizer as it does not allow for fine grained parallelism.
--jeff
ipv6 is my vpn
There was no 1997 IOCCC, there was an entry in 1996 by a Ken Huffman.. I am sure this is what you meant ;)
Look no further
This is a bunch of text to get past the "lameness filter". I'm tempted to make some pithy witticism about the basic lameness of lameness filters, but this should be sufficient.
I've finally had it: until slashdot gets article moderation, I am not coming back.
I humbly cast my vote on APL... It is a symbolic, naturally cryptic ( warning: big gif of the non-ASCII charset ) language, delightful to use ( once you really grokked it ) just because of the amazing power of its one-liners...:-)
Yes, that'd be to easy. Just any perl code would do. We could have a contest of the most readable, self-documenting and clearest perl code, though. But, then again, that might be too hard.
no casts or type conversions, really. Just know that:
/* default on unix systems */
;)
#define unix 1
(unix)["have"]+"fun"-0x60) == &("fun"[("have"[unix] - 0x60)]) == "un";
and the rest flows pretty easily. I was amazed by its simplicity once I figured it out (after reading the hints and lots of pondering w/ the C manual). And yes, it does use your favorite trick...
"It's overkill, of course. But you can never have too much overkill." - Anonymous Slashdot Coward
I was in the audience at that time. Note that most of the audience walked in were actually Mac developers. It was held in the same week, and across the street from, the World Wide Developer Conference held by Apple in San Jose.
If you're using COM interfaces it gets worse than that. The VARIANT_BOOL data type is defined as a 16-bit word taking the values False (0) and True (-1). As long as you test these against false there's not usually a problem, but if you test equal to true rather than is true, or if you negate the variable then weird things can happen. VB's Not operator blindly does a bitwise rather than logical negation even on Booleans, so if you take a Boolean variable (badly) returned from a COM object written in C++ it's entirely possible for both the following statements to get executed:
If var Then DoThis
If Not var Then DoThat
Solution: always return COM booleans from C++ using the idiom (var ? VARIANT_TRUE : VARIANT_FALSE)
This is my World Wide Web of Whatever