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. :-)"
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
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
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
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?
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.
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
(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.
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
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
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.
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.