Slashdot Mirror


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

50 of 144 comments (clear)

  1. Cute site by Matey-O · · Score: 2, Funny

    Anybody notice the 'A is for ASCII, B is for Byte' stuff on the winners index?

    link

    --
    "Draco dormiens nunquam titillandus."
  2. russians will win? by weinford · · Score: 2, Interesting

    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.
    1. Re:russians will win? by Anonymous Coward · · Score: 3, Funny
      It would not be the first time I read the assembly generated by the compiler to understand what the damned C code meant.


      There are cases, often with complex logical expression with deeply nested parenthese, && and ||, where the assembly is easier to read than
      the so called "high level" source code.
      (Well, C is not high-level in any case)

    2. Re:russians will win? by Anonymous Coward · · Score: 2, Informative

      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?

      It's a well documented phenomena.

    3. Re:russians will win? by jgerman · · Score: 2

      Russian Coders? How about U.S. gorvernment coders?

      --
      I'm the big fish in the big pond bitch.
    4. Re:russians will win? by empesey · · Score: 2

      Russians? Americans used to do the same thing. Maybe not with the misleading variable names, but obfuscation was part of the game. It wasn't until the 80s that people started shifting focus towards software development toward a more professional focus. During the 60s mostly (and into the 70s) you had the core-wars hacker types discovering what was possible and trying to push the envelope.

    5. Re:russians will win? by Anonymous Coward · · Score: 2, Funny

      > it's a nice story, that (once upon a time) russian coders liked to write code with obfuscation built in.
      > Can anyone confirm this?

      I have one story that is true.

      When I worked on image recognition software (1999), the boss decided that we needed a new recognition engine. So he paid for some source code written by a Russian (the guy didn't speak English, with almost no net acess, and limited access to a phone.)

      It was the worst piece of inefficient spagitti (crap) code I have ever seen. Variables names like j1, j2, j3, j4, j20, j22, and hardcoded array access like x[4] = , x[50] =, x[52] =. It took me a few months of reverse engineering and cleaning it up. I ended up just chucking it away, and starting from scratch, which was a valuable lesson for me -- If you're spending most of your time refactoring existing code, it's better to just chuck it away and start fresh with a clean design.

      > Maybe the compiled code is even easier to understand...

      It was! I also found it usefull to treat each function as a black box, and figure out
      a) input (& are they const)
      b) outputs (& are they const)
      c) intermediate values

      Ironically we had a co-worker Russion coder that was half decent. A little inexperienced on good coding practises, but a hard worker, and I could depend on him to get tasks done.

      Obviously 2 people isn't a large statistical enough sample to draw any conclusions from.

  3. When will they start an obfuscated perl contest? by forgoil · · Score: 3, Funny

    Or would that be too easy?;)

  4. my fovorite by snatchitup · · Score: 4, Funny

    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?

    1. Re:my fovorite by A+Big+Gnu+Thrush · · Score: 2

      It's Java.

  5. Other languages than C by Stackster · · Score: 2, Insightful

    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.
    1. Re:Other languages than C by tjgoodwin · · Score: 2, Informative
      If you think the IOCCC is mostly about ?:, then I don't think you've looked at enough entries! There is some truly twisted code in there, exploring every syntactic and semantic corner of the language.

      I doubt that other languages offer the same possibilities for befuddlement as C, but there's only one way to find out...

  6. That WOULD be too easy by Greyfox · · Score: 3, Insightful

    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?

  7. Anecdote by mirko · · Score: 5, Funny
    The following event was related by ace@tidbits.com (Adam C. Engst).

    The highlight of the annual Computer Bowl occurred when
    Bill Gates,
    who was a judge, posed the following
    question
    to the contestants:


    "What contest, held via Usenet, is dedicated to examples of weird, obscure, bizarre, and really bad programming?"


    After a moment of silence, Jean-Louis Gassee (ex-honcho at Apple) hit his buzzer and answered:


    "Windows."


    Mr. Bill's expression was, in the words of one who was there, "classic."
    --
    Trolling using another account since 2005.
  8. Re:When will they start an obfuscated perl contest by myelin42 · · Score: 3, Funny

    There already is one!

    Also, if you go to Perl Monks, there are heaps of people submitting obfuscated Perl code for judgement ...

  9. Re:Irony by hazem · · Score: 2, Insightful

    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.

  10. My favourite obfuscation by jasoegaard · · Score: 2, Funny

    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
    1. Re:My favourite obfuscation by skajohan · · Score: 2, Funny
      I'll try to compile and run it later when I have a break ;)

      Because you're now busy doing your job by reading Slashdot?

  11. Re:Irony by cdraus · · Score: 2, Insightful

    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.

  12. Re:When will they start an obfuscated perl contest by geirt · · Score: 2

    No need to, I have found a perfect auto obfuscater, it's called cat(1) ....

    --

    RFC1925
  13. Re:When will they start an obfuscated perl contest by microTodd · · Score: 2, Informative

    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
  14. Re:Is It Open to the Pros? by tb3 · · Score: 2

    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

  15. You wanna see really obscurifacted? by cdraus · · Score: 2, Interesting

    check out this

    and look under the C link.

  16. 1990 winner by Lussarn · · Score: 5, Interesting

    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.


    #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("=",' !' );}d=B;while(*F=*s){*s=='"'&&j
    ++;if(j&1||!Q(" \t",F))*d++=*s;s++;}*d--=j=0;if(B[1]!='=')switch(* B){X'E':l=-1
    X'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B) ,P [*d]=S():(*(q=Q(B,"TH"))=0,p
    =B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,pu ts (B+6):(p=B+5,printf("%d\n",S
    ()))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

    1. Re:1990 winner by Lussarn · · Score: 2, Informative

      Grab it here instead. The source where cut in the post.

    2. Re:1990 winner by Anonymous Coward · · Score: 2, Insightful

      I've always wished that they'd post an analysis of the various techniques used in each program. Sometimes the authors will explain some of the tricks they used, but it seems that most submitter's attitude is figure it out yourself.

  17. Re:When will they start an obfuscated perl contest by Andrewkov · · Score: 2

    All Perl programs are basically obfuscated, so a contest is not needed.

  18. a couple of my favs by gosand · · Score: 3, Interesting
    I have had these for a while now, not sure where I got them. I tried to post the source, but it wouldn't let me. Check them out.

    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.

  19. Damn it Jim! by Greyfox · · Score: 3

    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?

    1. Re:Damn it Jim! by Amazing+Quantum+Man · · Score: 2

      You don't use COBOL, you use the Object-Oriented version:

      ADD 1 TO COBOL STORING THE RESULT IN COBOL

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
  20. Abuse of the rules by DeadMeat+(TM) · · Score: 2
    The best ones have always been those that abuse the rules, the compiler, or both.

    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.

    1. Re:Abuse of the rules by joshwalker · · Score: 2, Informative

      There are some good examples of quines (self-replicating programs) at http://www.nyx.net/~gthompso/quine.htm

      Also, I like Esoteric Topics in Computer Programming

  21. Re:hare-brained by dstone · · Score: 2, Funny

    H4R3-br41N3D, not hare-brained, not hare-braned, not hare braned, not hair brained.....

  22. BZZT by Craig+Davison · · Score: 2, Informative

    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.

  23. new to this contest by chongo · · Score: 5, Informative
    As part of the IOCCC tradition, we always tweak/adjust the rules and guidelines each year. Noteworthy changes for the 16th contest include:
    • New max size limits: 4096 (was 3217)
      (We gotta keep up with the code bloat like everyone else :-) :-()
    • New max size for non-whitespace / non {:} chars: 2048 (was 1536)
    • New max compile/build line: 521 (was 255)
      (why 521? Well 521 is prime and 2^521-1 is a Mersenne prime and I like primes ... :-))
    • We now allow people to use OpenMotif
    • MS gets two pot shots directed at it in this contest (yet another tradition)
    --
    chongo (was here) /\oo/\
  24. Re:and the ever popular by slickwillie · · Score: 2

    (boolean expression) ? TRUE : FALSE;

  25. I have wanted to ask... by h2odragon · · Score: 2, Funny

    "Ken (a 1997 winner of the IOCCC)"

    Do you point this accomplishment out to prospective employers? Do they view it as a positive thing? :)

  26. Re:Irony by Ayende+Rahien · · Score: 2

    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?
  27. Re:Irony by cmowire · · Score: 2

    Actually, outside of deliberately confusing syntax, the relitive terseness of a langue really doesn't matter.

    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 := x+1 or x := x+2

    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.

  28. Unobfuscaters? by scott1853 · · Score: 2, Funny

    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.

  29. Very old idea: Job security by devphil · · Score: 2


    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)
  30. Stress test C Compilers? by chongo · · Score: 2, Informative
    Typically each year we find that at least 1 entry that will cause someone's C compiler to dump core or go haywire.

    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) /\oo/\
  31. Re:Irony by cmowire · · Score: 2

    I have often thought about that the := vs. = and == vs = issue.

    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 := be the assignment and then make == the equality comparison, to make things crystal clear.

    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.

  32. Seg: readable perl by TMB · · Score: 2

    Segfault had a classic article about the First Annual Readable Perl Contest about a year ago... :-)=

    [TMB]

  33. Re:When will they start an obfuscated perl contest by Loligo · · Score: 2, Funny


    Perl takes me back, though.

    Every time I look at someone else's perl, I expect a line to end with "NO CARRIER"...

    -l

  34. Re:and the ever popular by slickwillie · · Score: 2

    So I guess it's not really a "C compiler, is it?

  35. Re:Irony by statusbar · · Score: 2

    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
  36. Re:When will they start an obfuscated perl contest by scrytch · · Score: 2

    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.
  37. Re:Is It Open to the Pros? (SPOILERS) by ChadN · · Score: 2

    no casts or type conversions, really. Just know that:

    #define unix 1 /* default on unix systems */

    (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
  38. Correct by DreamerFi · · Score: 2

    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.