Slashdot Mirror


IOCCC Winners Announced

Arachn1d writes "The IOCCC has finally announced the winners of the 2004 contest.
With winners this year including a mini-OS and a ray-tracer, the submissions should be interesting indeed - if you can make sense of them. According to the page, the actual code for the winners should be up mid-october."

175 comments

  1. Obfuscation by BoldAC · · Score: 5, Informative

    For those who don't know what this is all about...

    It's all about how to obfuscate baby!

    1. Re:Obfuscation by Anonymous Coward · · Score: 5, Interesting
    2. Re:Obfuscation by Davak · · Score: 3, Informative
    3. Re:Obfuscation by gfxguy · · Score: 1

      As if anyone needed any help....

      --
      Stupid sexy Flanders.
    4. Re:Obfuscation by Anonymous Coward · · Score: 0

      As if anyone needed any help....

      Yes, that's exactly the joke he was making by linking to the official Perl documentation. Talk about missing the point...

    5. Re: Obfuscation by Black+Parrot · · Score: 2, Funny


      > For those who don't know what this is all about...

      Darn. I clicked it in hopes of seeing pix from the International Olympic Committee Contortionist Competition.

      > It's all about how to obfuscate baby!

      Was the article text one of the contest entries?

      --
      Sheesh, evil *and* a jerk. -- Jade
    6. Re:Obfuscation by h4rm0ny · · Score: 3, Informative


      How to obfuscate in copious detail.

      How to write unmaintainable code

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    7. Re:Obfuscation by revividus · · Score: 2, Funny

      But I wanted a link to "How to write intelligible code in Perl..." Caveat: I like perl. :-)

    8. Re:Obfuscation by rgmoore · · Score: 0

      To write intelligible code in Perl you just have to follow a few basic rules, most of which are not Perl specific:

      1. use warnings;
      2. use strict;
      3. Choose meaningful variable names.
      4. Use conventional, straightforward algorithms instead of clever, hard to follow ones.
      5. Break out complicated things into their own subroutines.
      6. Include useful comments that explain why you are doing what you're doing.
      7. Use standard modules instead of doing everything yourself.
      8. Use an editor that will autoindent for you.

      If you follow these rules, you'll be surprised at how readable your code becomes.

      --

      There's no point in questioning authority if you aren't going to listen to the answers.

    9. Re:Obfuscation by ameoba · · Score: 1

      Here's a bit of python obfuscation for you...

      print (lambda A,D,B,C,E,F,G,H,Q:"\n".join(["".join([(Q[int(
      __i mport__( "math").log((reduce(lambda x,y:abs(x[1])=D and
      (x[0]+1,x[1]**2+y[1]) or x,[(0,complex(r/B,i/B))]*A))[0]+1)
      )%len(Q)]) for i in range(F*B,G*B,H)]) for r in range(C*B,
      E*B,H)]))(1500,4,100.0,-2.25,1.5,-1.25 ,1.25,4,".^: /I&@*%$#")

      I know there's no way this is getting past the lameness filter.

      --
      my sig's at the bottom of the page.
    10. Re:Obfuscation by hackstraw · · Score: 1

      One of the nastiest pieces of code that I had to do maintenance work on involved a smartcard application where one of the data elements was a simple integer that the programmer before me decided to encode in ascii text randomly in hex or decimal. It was easy to figure out for numbers 10 and below, but for those other numbers... I'm glad I don't work there any more.

    11. Re:Obfuscation by DAldredge · · Score: 1

      Cool.

      I can use this as an example as why not to program in python. Kind of like the way the /. python crowd throws perl one lines up as a reason that perl is a write only language. ;->

    12. Re:Obfuscation by Anonymous Coward · · Score: 1, Insightful

      Of course to be fair, I don't know of any language that's readable once you strip out all the end-of-line characters...

    13. Re:Obfuscation by Threni · · Score: 1

      > For those who don't know what this is all about... ...and who aren't prepared to RFTA, you mean?

      Their website still sucks!

      > We need more mirrors, particularly in locatins where we have none at the
      > momemt. Are you willing to mirror the IOCCC web site?

      They seem to be applying their principle of obfuscation to the text. Who knows, perhaps the site's HTML is also similarly manipulated, which would explain why it's sucked so hard, year after year!

    14. Re:Obfuscation by Anonymous Coward · · Score: 0

      Python, generally, is hard to strip EOL chars from. This example is actually a single statement; something a lot harder to do than taking a snippet of Perl or C and removing all the newlines.

  2. Umm by stratjakt · · Score: 3, Interesting

    Who's the IOCCC and what was this contest about? Some programming thing obviously. Is this that obfuscated perl thing?

    Seriously, a sentence or two of information in the submissions doesn't hurt.

    --
    I don't need no instructions to know how to rock!!!!
    1. Re:Umm by TheShadowHawk · · Score: 5, Funny

      Maybe that's the whole point. Everything (including the article) is well... obfuscated.

      --
      Friends don't let Friends use Internet Explorer.
    2. Re:Umm by ophix · · Score: 5, Funny

      wouldnt it need to be an UNobfuscated perl code contest? ;}

    3. Re:Umm by Anonymous Coward · · Score: 1, Informative

      It's a very well known contest for obfuscated C code. You should already know that, though.

    4. Re:Umm by skribble · · Score: 2, Funny

      Apparently even the web site is obfuscated now.

      --
      --- Nothing To See Here ---
    5. Re:Umm by lachlan76 · · Score: 0, Redundant

      IOCCC is the International Obfuscated C Code Contest.

      The whole point is to make working code which no-one can read.

    6. Re:Umm by Anonymous Coward · · Score: 0

      Who's the IOCCC and what was this contest about?

      Which letter in RTFA confuses you?

      Oh, I guess a sentence in required for those who don't know what RTFA means and are too lazy to look it up. Read the fucking article.

    7. Re:Umm by bob+whoops · · Score: 1

      I think he understood, he just was saying that it was not very informative. Sure you say RTFA, but then, why not have the entire submission just be a link to the artice?

  3. Windows CE? by wackysootroom · · Score: 4, Funny

    Was the Mini-Os Windows CE by any chance? I'd bet that's pretty obfuscated!

    1. Re:Windows CE? by Anonymous Coward · · Score: 0

      Was the Mini-Os Windows CE by any chance? I'd bet that's pretty obfuscated!

      As always Microsoft-bashing gets a high score. I bet it wouldn't have got 5 if parent had used something other than Windows CE.

    2. Re:Windows CE? by theCoder · · Score: 1

      No, no, the code had to work :)

      (This is mostly a joke, but I do use the reboot button on my iPaq much more than several of the other buttons)

      --
      "Save the whales, feed the hungry, free the mallocs" -- author unknown
  4. Much better than the last 2 years by dtfinch · · Score: 3, Insightful

    When there was no contest at all. "Yeah, everyone send in your entries. Oh, nevermind, maybe next year."

    Of course it looks like those extra 2 years paid off. This year's winners look very interesting.

    1. Re:Much better than the last 2 years by Yeechang+Lee · · Score: 1
      When there was no contest at all. "Yeah, everyone send in your entries. Oh, nevermind, maybe next year."

      Of course it looks like those extra 2 years paid off. This year's winners look very interesting.

      Not only that, those extra two years gave me the chance to polish up my GPLed x86 virtual machine that runs Windows XP and all applications at 100% speed under Linux or *BSD. And it's only 2K! Although I sadly just missed the IOCCC deadline due to some last-minute optimizations, here's the source, making its world debut:
      #include <stdio.h>
      #defin@#S@#$!!@#$
      NO CARRIER
  5. If the IOCCC is like the IOC by Omega1045 · · Score: 5, Funny

    If the IOCCC is anything like the IOC, I am sure they will ask some of the winners to give back their prizes because of judging mistakes, and probably screwed over several Russian participants.

    --

    Great ideas often receive violent opposition from mediocre minds. - Albert Einstein

    1. Re:If the IOCCC is like the IOC by loconet · · Score: 1

      and will sue any /. posters that post mirrors to the source code.

      --
      [alk]
    2. Re:If the IOCCC is like the IOC by leob · · Score: 1

      Unlike IOC, we have no idea if there were any Russian (or Korean, or Brasilian, for that matter) participants this year. The identities of the authors are kept away until we agree on the set of winners.

    3. Re:If the IOCCC is like the IOC by Anonymous Coward · · Score: 0

      Just some clarification. It's the FIG asking Hamm to return the medal, NOT the IOC. The IOC has flatly refused to endorse this request.

    4. Re:If the IOCCC is like the IOC by Anonymous Coward · · Score: 0

      I've heard rumours that some of the participants were using ritalin too.

  6. The coolest thing... by Anonymous Coward · · Score: 0

    ...was somebody built a hamster-powered webserver for the IOCCC hosting. I wonder how well it performs?

  7. Let me be the first to say... by GillBates0 · · Score: 3, Funny
    10333 r0x0rzz. 0bf534710n rul3zz!

    C0N6R47UL4710N5 W1NN3RZZ!

    --
    An Indian-American Hindu committed to non-violent thought/speech/action alarmed by the global explosion of radical Islam
    1. Re:Let me be the first to say... by Short+Circuit · · Score: 2, Funny

      What's really, really scary, is that I could read that just fine...

    2. Re:Let me be the first to say... by UserGoogol · · Score: 1

      7h475 n07 5c4r'/ 47 411. 1337 15 57\/p1d1'/ 342'/ 70 |)3(0|)3.

      --
      "Never attribute to malice that which can be adequately explained by stupidity." -- Hanlon's Razor
    3. Re:Let me be the first to say... by gilrain · · Score: 1

      Translation: that's not scary at all. Leet is stupidly easy to decode.

  8. I can smell the smoke from here... by pedestrian+crossing · · Score: 4, Informative

    Since the summary isn't very informative, and the servers are rapidly slowing down, it is the International Obsfucated C Code Contest. About all that is (was?) on their page is the list of winners...

    --
    A house divided against itself cannot stand.
  9. Additional Mirror by pikine · · Score: 5, Informative

    us1 mirror and see Google cache for more.

    --
    I once had a signature.
  10. Site content by houghi · · Score: 5, Informative

    Not much. No source code yet. Here is the content of the site:

    Here are the names and categories for the winners of the 17th IOCCC. The source code has not been released yet. The winners have been notified by EMail. They will be given a chance to review the write-up of their entry. Once this process is complete the source code will be made available on the winning entries web page. We anticipate that this will be in mid-October.

    The winners are,

    * Best of Show

    Gavin Barraclough - Mini-OS
    Manchester, UK

    screenshot

    * Best One-Liner

    Eryk Kopczynski - OCR of 8, 9, 10 and 11
    Warszawa, Poland

    * Best Utility

    Don Yang - A CRC inserter
    Covina, California, USA

    * Best Non-Use of Curses

    Mark Schnitzius - Editor animation
    Singapore

    * Best X11 Game

    Daniel Vik - X Windows car racing game
    La Jolla, California, USA

    screenshot

    * Best use of "Precious" Lines

    Anonymous - Rendering of a stroked font
    Singapore

    screenshot

    * Best Abuse of CPP

    Daniel Vik - Calculates prime numbers using only CPP
    La Jolla, California, USA

    * Best Calculated Risk

    Brent Burley - A Poker game
    Burbank, California, USA

    * Best use of Vision

    Nick Johnson - Curses maze displayer/navigator with only line-of-sight visibility
    Christchurch, New Zealand

    * Best Font Engine

    Jeff Newbern - Renders arbitary bitmapped fonts
    Springwood, Queensland, Australia

    * Most Functional Output

    Jonathan Hoyle - Curses based polynomial graphing with auto-scale
    Ann Arbor, Michigan, USA

    * Best use of Light and Spheres

    Anders Gavare - A ray tracer
    Gothenburg, Sweden

    screenshot

    * Best Abuse of Indentation

    Stephen Sykes - Space/tab/linefeed steganography
    Helsinki, Finland

    * Best Abuse of the Guidelines

    Anthony Howe - A CGI capable HTTP server
    Cannes, France

    * Best Abuse of the Periodic Table

    John Dalbec - Conway's look'n'say sequence split into elements
    Canfield, Ohio, USA

    --
    Don't fight for your country, if your country does not fight for you.
    1. Re:Site content by SILIZIUMM · · Score: 0, Offtopic

      Damn you beat me by 2 minutes :) I wanted to paste the original HTML but Slashdot complained because "Your comment has too few characters per linetoo short lines" (?). So I pasted the content without the formatting just like you did. Heh, still funny.

  11. Mirrors by lachlan76 · · Score: 5, Informative

    Before it all goes down, here are the mirrors:

    Asia
    * http://www.tw.ioccc.org/ - Hsin-Chu, Taiwan (24 48' N 120 59' E)

    * Australia and other Pacific http://www.au.ioccc.org/ - Sydney, Australia (34 0' S 151 0' E)

    Europe
    * http://www.de.ioccc.org/ - Hamburg, Germany (53 33' N 10 2' E)
    * http://www.es.ioccc.org/ - Madrid, Spain (40 25' N 3 41' W)
    * http://www.gr.ioccc.org/ - Athens, Greece (38 00' N 23 44' E)
    * North America www0.us.ioccc.org - Sunnyvale California, US (37 22' N 122 02' W)
    * www1.us.ioccc.org - Saint Paul, Minnesota US (44 57' N 93 06' W)

  12. Time to turn in your geek card... by GillBates0 · · Score: 4, Funny
    Every self respecting geek knows what the IOCCC is. By admitting that you don't, you've demonstrated your inability to cope with the rigorous demands of abiding by the high standards of geekiness.

    Please hand in your Geek membership card on your way out. Thank you.

    --
    An Indian-American Hindu committed to non-violent thought/speech/action alarmed by the global explosion of radical Islam
    1. Re:Time to turn in your geek card... by stratjakt · · Score: 0

      Never had one, never even applied for one.

      Not only that, I don't consider the ability to churn out unreadable code a good trait in a programmer. Nothing geeky about it, just sloppy.

      As I understand it, this contest is basically "who can turn out the shittiest code that still runs?"

      Note to unemployed IOCCC contest winners. Don't try to play this up on your resume.

      --
      I don't need no instructions to know how to rock!!!!
    2. Re:Time to turn in your geek card... by mirko · · Score: 1

      Well, not Jean-Louis Gassee who was considered a visionary among geeks...

      --
      Trolling using another account since 2005.
    3. Re:Time to turn in your geek card... by lachlan76 · · Score: 4, Insightful

      Not only that, I don't consider the ability to churn out unreadable code a good trait in a programmer

      To be able to make something like that, you need to be able to understand the language well, which is a good thing.

    4. Re:Time to turn in your geek card... by Emil+Brink · · Score: 5, Insightful

      Whoa there, turn up the humour and creativity-appreciation knobs a couple of notches please. I don't think anyone likes to see obfuscated code in production environments, but if you haven't read any IOCCC entries, you should. They can be real eye-openers when it comes to realizing what you can do with the C language (and preprocessor) when put in the right hands. Plus, it's just plain fun! :)

      --
      main(O){10<putchar(4^--O?77-(15&5128 >>4*O):10)&&main(2+O);}
    5. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 4, Insightful

      As I understand it, this contest is basically "who can turn out the shittiest code that still runs?"

      (1) It's for fun.
      (2) It's a famous tradition.
      (3) There is a great elegance in the entries which win; they are far from shitty.
      (4) Chill out.

    6. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0

      Heh. You've been outclassed by a +5 Funny and you can't bring the troll back from that.

      Note to unemployed IOCCC contest winners. Don't try to play this up on your resume.

      Unless, of course, you're applying for a job to write source code obfuscators.

    7. Re:Time to turn in your geek card... by stratjakt · · Score: 0

      No, you need to have a poor understanding of the language. You need to merly know syntax, but not the intent.

      You need to be willing to replace standard library math calls with unreadble one-line pieces of crap. You need to pick undescriptive one-letter variable names.

      You need to think that recursion is a good solution to simple problems like factorial, and that it's appropriate to jam function calls and assignment operators into if and for declarations, etc.

      Plenty of folks out there think this is "good programming". If it's too readable then it's "dumb".

      Mechanics could have a contest to see who could to the shittiest job on an old car and get it running. They can pack the transmission with sawdust, jack it up on hockey pucks, do every "ghetto" technique in the book. You may say they're very knowledgeable about cars, you may even call them great mechanics. But I wouldn't take my car to one.

      --
      I don't need no instructions to know how to rock!!!!
    8. Re:Time to turn in your geek card... by torpor · · Score: 2, Informative

      Not only that, I don't consider the ability to churn out unreadable code a good trait in a programmer. Nothing geeky about it, just sloppy.

      i consider the ability to at least appreciate unreadable code, and have a good time with it, for fun, just coz, to be a good trait in a programmer. and thats what this IOCC thing is. for fun.

      (thus you're fired! hand in your geekcard on the way out...)

      --
      ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
    9. Re:Time to turn in your geek card... by lachlan76 · · Score: 1
      Well, it shows:
      • Memory
      • Creative thinking
      And it's not like doing a shitty job repairing a car - It's not that they don't work, just nobody understands them.
    10. Re:Time to turn in your geek card... by Mateito · · Score: 1
      Not only that, I don't consider the ability to churn out unreadable code a good trait in a programmer.

      Just consider it... insurance.

      Obfuscate... or be outsourced.

    11. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0

      It's exactly like doing a shitty job on a car. the shitty job on the car may work as well, but it's ugly as hell and nobody else wants any part of it.

      And they're surprised when it works.

      But keep deluding yourself into thinking that obfuscated code is some indicator of skill if it makes you better. Just ignore for your own piece of mind that any monkey can write obfuscated code, but employers aren't going to hire that monkey, because obfuscated code isn't a marketable skill.

    12. Re:Time to turn in your geek card... by stratjakt · · Score: 4, Funny

      Here's an example of what I'm talking about:

      I got a resume from some kid just out of University. He attached some samples of the code he wrote. One of them was the perennial "calendar" app that I think we all were tasked to write.

      Anyhow, I was perusing the code. It was pretty sloppy, one-letter variable names, multiple statements crammed together on single lines.

      So I get to this one section of code. I can't even remember how it worked now, but it was this convoluded for() statement that flipped a flag and did some weird ass computation. It took me about 10 minutes of "stepping through" it in my head to figure out what it was doing.

      It was calculating leap-years. I actually stared at it in shock, imagining how much time and energy this kid spent figuring out the worlds most assinine way to figure out if it's leapyear. I would have just wrote "if (year%4 == 0) { days_in_feb=29; }" or something of the sort. I wouldnt write "if (!(year%4)) {};" because perfoming boolean tests on integers is another pet peeve, it doesn't improve the code, just detracts slightly from its readability.

      I actually interviewed the kid, and pointed the lines out to him. I asked him why he didn't just use the modulus operator. He just stared at me blankly. He had no clue what "modulus" meant.

      As creative as his "solution" was, his code was bad, and he was a shitty programmer with a very very poor understanding of the language.

      It's all cool to have this contest, and if that's how people want to spend their spare time, go ahead. I'm just trying to send a message to the newbies reading slashdot who are still in school and tend to think this is a hallmark of a good coder in the "real world". In the real world or business, anything that makes your day more of a hassle than it needs to be, is a bad thing.

      Leave the obfuscation to the marketing department. We have one who actually listed double-ROT13 encryption as a "feature" of our product. Ok, he asked me what encryption we supported by default, and I told him double-ROT13 not realizing just how dense he was. The story gets better! The marketing shpiel he put together was going to the IT security folks at the NSA! One of them called me up, in tears from laughing. He asked if I could implement quad-ROT13. I told him I could implement 2^n-ROT13, iff n>0.

      But that's another story for another article.

      --
      I don't need no instructions to know how to rock!!!!
    13. Re:Time to turn in your geek card... by Ignignot · · Score: 1

      Please hand in your Geek membership card on your way out.

      Do I get to turn in my virgin card as well?? Please say its so!

      --
      I submitted this story last night, and it didn't get posted.
    14. Re:Time to turn in your geek card... by bhima · · Score: 1

      Yep I suppose this is fun for some but a bit like masturbating in public, not something you put on the CV!

      --
      Nothing in the world is more dangerous than sincere ignorance and conscientious stupidity.
    15. Re:Time to turn in your geek card... by UserGoogol · · Score: 3, Informative

      The IOCCC is a sort of piece of classic Hacker culture. That is to say, doing something difficult and mildly amusing just because you can. Also, to make fun of C for having such a ridiculous syntax as compared to sensible languages like Lisp. (Although by this day and age we've all grown up and seen Perl, so we don't care about that as much.)

      Anyway, this is not merely "bad code," in the sense that an idiot might program this stuff. This is the sort of code you can only attain when you actively aim for it. You really need to know the language well to know how to fuck with it so thoroughly.

      --
      "Never attribute to malice that which can be adequately explained by stupidity." -- Hanlon's Razor
    16. Re:Time to turn in your geek card... by Bastian · · Score: 3, Insightful

      Depending on where I'm applying, I would put winning the IOCCC on my resume. If you are looking at an employer who would know what it is, it shows that you have more knowledge of how computers and (at least) the C programming language work than most people. It doesn't show that you always turn out crappy code - those in the know also know that the IOCCC got its start with a bunch of skilled programmers ridiculing people who turn out crappy code.

      If they don't know, hey, it says you won a fairly well-known programming contenst.

    17. Re:Time to turn in your geek card... by Ford+Prefect · · Score: 1
      Calendar, eh? Let's have a look at what I've written in PHP. It's got that modulus operator, it's got logic, it's got variable names longer than a single character...

      But these few lines in particular show its true nature:
      for ( $day = 1 - ( $month_start['wday'] + 6 ) % 7;
      $day <= $month_end['mday'] + ( 6 - ( $month_end['wday'] + 6 ) % 7 );
      $day++ )
      {
      if ( ( $day + ( $month_start['wday'] + 6 ) % 7 ) % 7 == 1 )
      ...
      It's still completely unreadable. Argh!

      --
      Tedious Bloggy Stuff - hooray?
    18. Re:Time to turn in your geek card... by ComaVN · · Score: 4, Insightful

      Leave the obfuscation to the marketing department. We have one who actually listed double-ROT13 encryption as a "feature" of our product. Ok, he asked me what encryption we supported by default, and I told him double-ROT13 not realizing just how dense he was. The story gets better! The marketing shpiel he put together was going to the IT security folks at the NSA! One of them called me up, in tears from laughing. He asked if I could implement quad-ROT13. I told him I could implement 2^n-ROT13, iff n>0.

      Actually, I think you're the one who's dense, when you think someone from marketing who asks you a straightforward question about your product is supposed to understand a geek-joke.

      It's not his job to check or even understand all the technical info. It's (presumably) yours.

      --
      Be wary of any facts that confirm your opinion.
    19. Re:Time to turn in your geek card... by MORTAR_COMBAT! · · Score: 2, Informative
      It was calculating leap-years. I actually stared at it in shock, imagining how much time and energy this kid spent figuring out the worlds most assinine way to figure out if it's leapyear. I would have just wrote "if (year%4 == 0) { days_in_feb=29; }" or something of the sort.

      determining a leap year is more than just having it be divisible evenly by 4: The Gregorian calendar adds an extra day to February, making it 29 days long, in years divisible by 4, excepting years divisible by 100, but including years divisible by 400. So 1996, 2000, and 2400 are leap years but 1899, 1900 and 2100 are not.

      So following the literal description, in Java one might write:
      int iDaysInFeb_ = ( 0 != iYear_ % 4 ) ? 28
      : ( 0 != iYear_ % 100 ) ? 29
      : ( 0 != iYear_ % 400 ) ? 28
      : 29;
      Probably there are better and more optimized paths than this... but hey, at least I checked to make sure it compiled and worked :)
      --
      MORTAR COMBAT!
    20. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0
      Thats all well and good but your calculation is incorrect.

      A year is a leap year if it is modulo 4, except when it occurs at the turn of a century (modulo 100) when the century also needs to be modulo 4.

      Your function should therefore be "if (year%4==0 && (year%100!=0 || year%400==0)) { days_in_feb=29 }"

    21. Re:Time to turn in your geek card... by lachlan76 · · Score: 1
      I told him double-ROT13 not realizing just how dense he was. The story gets better! The marketing shpiel he put together was going to the IT security folks at the NSA! One of them called me up, in tears from laughing

      I just had the exact same reaction. You posted this over 30 minutes ago. I'm still laughing out loud now.

      I'm still a newbie too, but spending a while coding assembly straightened me out. That and seeing the code from one of my friends from school who started C++ a couple of weeks ago. Scared the shit out of me. Haven't had a single memory leak since. Most of the mistakes you mentioned does piss me off though. That and opening braces on the same line as the start of a function/class/loop/struct/etc. But that's just me.

      What I'd recommend to the other newbies out there is to download something simple from Sourceforge, go through it, try to understand it, and rewrite it yourself, if it's simple enough (I did md5sum, reusing some code from md5lib). Try either that or 2^n-ROT13, where n > 0 ;)

      The only other way I can think of that could check whether a year is a leap year would be
      bool leapYear = (year & 0x3) ? false : true;
      Which, if I understand correctly, would run faster, because there's no division involved. Not that performance really matters in a calendar.
    22. Re:Time to turn in your geek card... by jhines0042 · · Score: 1
      BTW, your code above is wrong. To correctly calculate leap years you need to account for the 100 year skips of leap years, and the 400 year exception to the skip. Like below.


      days_in_feb = 28;

      if(year%4 == 0)
      {
      days_in_feb = 29;

      if(year%100 == 0 && year%400 != 0)
      {
      days_in_feb = 28;
      }
      }



      So if you are going to pick on programmers for bad code, at least make sure your algorithms are correct.
      --
      42 - So long and thanks for all the fish.
    23. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0

      LOL, your post is funny in more ways than one, because it sounds like neither one of you has the correct solution.

    24. Re:Time to turn in your geek card... by magefile · · Score: 1

      Er ... it's not that simple. If it's a century year, it's not a leap year, unless the number of years is divisible by 400 (i.e., 2000 was a leap year; 2100 won't be).

    25. Re:Time to turn in your geek card... by staticdaze · · Score: 1

      calculating leap years is a tad more complicated than just year % 4. You can make a pretty conditional statement to do it, like so:

      sub IsLeapYear { my $year = shift; return $year % 4 ? 0 : $year % 100 ? 1 : $year % 400 ? 0 : 1; }

      This example (in Perl of course) is taken from an O'Reilly Book

    26. Re:Time to turn in your geek card... by pthisis · · Score: 1

      As I understand it, this contest is basically "who can turn out the shittiest code that still runs?"

      No, the obfuscation is often secondary, or at least the "don't indent, use one-letter names" portion of the obfuscation.

      Example of a past winner:
      The output of the entry was a program that would flip an input text file on a diagonal axis. So e.g.:

      ab
      cd

      was turned into:

      ac
      bd

      Simple, right? Sure, but the source code itself was such that if it was flipped on the axis, it became compileable source code to another program that flipped the input text on the other diagonal:

      ac
      bd

      became

      dc
      ba

      And when that was run on the second program, it became compileable source for a program that flipped the input across the horizontal axis, to:

      ba
      dc

      And when that was run on the third program, it became compileable source for a program that flipped the input across the vertical axis, to:

      ab
      cd

      which was the original source code.

      You can't tell me that writing source code that can be flipped on its axes 3 times to generate 4 different legal C programs isn't pretty damned clever. Useless, but clever.

      So it's not about shitty code, it's about useless but very elegant code.

      --
      rage, rage against the dying of the light
    27. Re:Time to turn in your geek card... by Carnildo · · Score: 1
      It was calculating leap-years. I actually stared at it in shock, imagining how much time and energy this kid spent figuring out the worlds most assinine way to figure out if it's leapyear. I would have just wrote "if (year%4 == 0) { days_in_feb=29; }" or something of the sort. I wouldnt write "if (!(year%4)) {};" because perfoming boolean tests on integers is another pet peeve, it doesn't improve the code, just detracts slightly from its readability.

      What's so hard about something like
      int days_in_february(int year)
      {
      return 28 + (((year % 4) == 0) - ((year % 100) == 0) + ((year % 400) == 0))
      }
      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    28. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0

      Your way might be simple, but it's also wrong. K&R covered this:

      leap = (year%4 == 0 && year%100 != 0) || year%400 == 0;

    29. Re:Time to turn in your geek card... by MORTAR_COMBAT! · · Score: 1

      Your implementation of the leap year calculation mistakenly identifies the year 2100 as a leap year (it is not). However I do applaud the appropriate use of the bitwise and operator.

      --
      MORTAR COMBAT!
    30. Re:Time to turn in your geek card... by MORTAR_COMBAT! · · Score: 2, Informative

      your implemetation begs the question: is it better to perform 3 division and 3 addition operations, or simply 3 division and 3 comparison operations?

      on my PC it turned out that it takes twice as long to go the route of strange addition ;]

      --
      MORTAR COMBAT!
    31. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0

      All current optimizing compilers can be relied on to optimize (x % 4) into (x & 3). The former expresses the intent of the test, the latter is just the kind of smart-aleck trickery that we're all disdaining in this thread.

    32. Re:Time to turn in your geek card... by SirPrize · · Score: 1

      To those who want to know, the program is the schnitzi program, submitted in 1994.

    33. Re:Time to turn in your geek card... by NichG · · Score: 1

      Very few monkeys could write obfuscated code that works though. Don't think of this as a programming contest - think of it as a form of cryptography contest.

    34. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0
      MORTAR_COMBAT! wrote:
      Probably there are better and more optimized paths than this...
      That's the least you could say. For instance:
      day=year&0x3?034:0x1d-(year%0x190&&1)^ ( year% 0144&&1) ;
      . Of course, you could still optimize it with something like:
      sed s,year,y,g
    35. Re:Time to turn in your geek card... by Anonymous Coward · · Score: 0

      Could somebody tell me why this actually works?

    36. Re:Time to turn in your geek card... by MORTAR_COMBAT! · · Score: 1
      First of all, it doesn't compile in the specified language (Java) because it uses the nasty trick of using integers where booleans are reguired by the grammar, but let's step through it, shall we?

      Your AC parent wrote:
      day=year&0x3?034:0x1d-(year%0x190&&1)^ ( year% 0144&&1) ;
      Written more sensibly (some spaces because HTML and code often mix poorly!), this becomes:
      day = ( year & 0x3 )
      ? 034
      : 0x1d-(year%0x190&&1)^ ( year% 0144&&1)
      ;
      This parses generally into:
      day = ( if ? then : else )
      The if part, year&0x3, is expounded upon in another post in this tree. But basically you do a "bitwise and" of the year with the integer "0x3", which in binary has the same effect as getting the remainder when dividing by 4. In most programming languages, specifying an integer using the "0x" prefix means it is a hexadecimal number.

      So, if there is a remainder when dividing by 4, then the answer is 034 -- this is a good time perhaps to mention that placing a leading "0" to an integer declares that it shall be given in octal. So 4 times 8 to the power of 0 (4) plus 3 times 8 to the power of 1 (24) gives us the decimal integer 28.

      The else part is littered with more of this kind of tom-foolery -- hexadecimal mixed with octal, all the while using the "int as boolean" tricks which are allowed in languages such as C and Perl, but not in all languages (Java does not allow performing a logical and with an integer of course, as logical operators should operate on boolean parameters!). So the answer will be given by 0x1d (again this is hex - in decimal this is 29) minus the "bitwise xor" of two values. Obviously, this "bitwise xor" will evaluate to either 0 or 1 (since there are 29-0 or 29-1 days in February). The LHS of this "bitwise xor" is the "logical and" of 1 (true) and the remainder given when you divide the year by "0x190" -- given again in hex here, this evaluates to 9 times 16 plus 1 times 256 -- 400! The RHS of the "bitwise xor" is the "logical and" of 1 (true) and the remainder given when you divide the year by "0144" -- octal for the decimal 100. If you are familiar with how the "xor" works (when one, and only one, of the expressions has 1 in a binary digit, the result has a 1 in that digit. Otherwise, the result has a 0 in that digit. By using the "logical and" prior to the "xor", the AC ensured that there will be either a "1" (true) or "0" (false) on either side of the "xor". Since the special case of the leap year's existence is determined by being divisible by 100 (and also NOT divisible by 400!) the AC has provided an interestingly-obfuscated look at what boils down to:
      day = ( year % 4 )
      ? 28
      : 29 - (year%400&&1)^ ( year% 100&&1)
      ;
      I'm not going to bother myself with the performance of this method vs. the performance of any other method. Suffice it to say it is readable to some people, and not so readable to others. The vast majority of people, and even most "coders" would find it hard to read, even as presented here at the end without the layer of octal- and hexadecimal- notation.

      This is what is supposedly known as, in layman's terms, "job security".
      --
      MORTAR COMBAT!
    37. Re:Time to turn in your geek card... by jonadab · · Score: 1

      > Anyhow, I was perusing the code. It was pretty sloppy, one-letter variable
      > names, multiple statements crammed together on single lines.

      Done correctly, multiple statements on a line can actually make code easier
      to read, by allowing more of the context to fit on the screen at once. It's
      harder to defend one-letter variable names, except perhaps for very tightly
      scoped lexicals, where you can see every reference to the variable in a small
      handful of lines.

      > So I get to this one section of code. I can't even remember how it worked
      > now, but it was this convoluded for() statement that flipped a flag and
      > did some weird ass computation. It took me about 10 minutes of "stepping
      > through" it in my head to figure out what it was doing.

      Heh. C-style for loops are a pet peave of mine. Fortunately, they're going
      the way of the dodo in Perl6, and all for loops will really be foreach loops.
      (Oh, you're still programming in C? I'm sorry.)

      > It was calculating leap-years. I actually stared at it in shock, imagining
      > how much time and energy this kid spent figuring out the worlds most
      > assinine way to figure out if it's leapyear. I would have just wrote
      > "if (year%4 == 0) { days_in_feb=29; }" or something of the sort.

      That would get the answer wrong sometimes. I would write something like
      use DateTime; if (DateTime->now->is_leap_year()) { whatever() }

      --
      Cut that out, or I will ship you to Norilsk in a box.
    38. Re:Time to turn in your geek card... by anynameleft · · Score: 1
      "I told him I could implement 2^n-ROT13, iff n>0."

      Are you sure you don't mean 2n-ROT13? That even works for n=-2 or n=0.

      Besides that, we all know that Pascal is the perfect language to write readable code.

      function isLeapYear(x:
      integer): boolean; var
      c: integer; label b, c,
      p, q, r, x, y, x; begin
      goto q; x: if x mod 4 = 0
      then goto p; b: if x mod
      100 = 0 then goto r; y:if
      x mod 400 = 0 then goto c;
      goto z; p: c := 29; goto b;
      q: c := 28; goto x; r: c :=
      28; goto y; c: c := 29; goto
      z; z: result := c=29; end;
    39. Re:Time to turn in your geek card... by Lozzer · · Score: 1
      PS:Slashdot's 10^7th comment

      You make disparaging comments about somebody's geekiness and yet you casually fling off a signature about powers of ten as if any geek would care...:-)

      --
      Special Relativity: The person in the other queue thinks yours is moving faster.
    40. Re:Time to turn in your geek card... by lachlan76 · · Score: 1
      After seeing how much faster
      for(int i = 250; i > 0; i--)
      {
      w++;
      x++;
      y++;
      z++;
      }
      n = w + x + y + z;
      was than
      for(int i = 1000; i > 0; i--)
      n++;
      I have lost some trust in my compiler's optimisations.

      And how much worse is
      bool leapYear = (year & 0x3) ? false : true; //Check for leap year, same as (year % 4)
      than
      bool leapYear = (year % 4) ? false : true; //Check whether this is a leap year


      Besides, I learnt assembly before C++, so I do my own optimisations out of habit.
  13. Funny, but sickening by Anonymous Coward · · Score: 5, Insightful

    I always though this contest was funny, but in a dark and sinister way. I can't tell you how many times I've looked at someone else's code and spent hours trying to figure it out. In the real world, it's not funny.
    I'm amazed at how someone can acheive such obfuscated code without really trying.

    1. Re:Funny, but sickening by lachlan76 · · Score: 0, Offtopic

      Almost as bad as English really... ;)

    2. Re:Funny, but sickening by Ignignot · · Score: 2, Insightful

      I'm amazed at how someone can acheive such obfuscated code without really trying.

      I'm not amazed at all - I pay special attention to my code so that someone else could come in and use it. That doesn't mean they'll be able to just step in and understand everything, it'll be hard no matter what. But if I didn't try, I think everything I made would be unusable by anyone else. In my mind that makes the code worth very little - it is the ability to reuse code that makes it valuable. I've debugged or added features to other people's programs (once in VB / Access, [shudder]) and it can be a nightmare even with comments. I think that most of the time people get into a coding zone and they're able to just chug through 100 lines or more at once, holding the entire program in their head for awhile. The problem is, if you do that you usually don't comment well (if at all). I try to proofread everything I write, putting comments back in, but for most people it isn't worth the effort. "It compiles, runs correctly, I'm done! Time to surf slashdot!"

      --
      I submitted this story last night, and it didn't get posted.
    3. Re:Funny, but sickening by msgregory@earthlink. · · Score: 0, Flamebait
      Newbie C programmers get all into this kind of crap. They think it makes them look smarter or something. It really doesn't, it makes them look like newbies. I guess they get a rush from thinking that noone else is smart enough to read their code, like they're some kind of elite genious or something.

      I think the same thing every time I hear about this contest. Truth is, who is dumb enough to take the time to read code like that?

    4. Re:Funny, but sickening by Anonymous Coward · · Score: 3, Insightful

      Somebody mod this prick down, he's in desperate need of a sense of humour.

      The whole point of the IOCCC is to demonstrate how ridiculously unreadable C programs can get if you really try. And if you don't think writing a raytracer or whatever within the guidelines set in the competition rules is worthy of admiration then you've never picked up a C compiler in your life.

      I see you have a job that requires you to read CVs and presumably hire people. Please tell us which company this is so we can avoid this miserable establishment.

    5. Re:Funny, but sickening by Anonymous Coward · · Score: 0

      Recursion too, every newbie programmer who learns recursion wants to use it for every frickin problem. In reality, it's rarely a good solution. We all learned recursion with the factorial example, imagine 20!. With recursion you get 20 function calls with all their associated overhead. A for loop is a much better solution.

      Only if you're using a shitty language or compiler that can't handle trivial optimisations like tail call elimination.

    6. Re:Funny, but sickening by micromoog · · Score: 2, Insightful

      People do this for fun. This has nothing to do with productivity, the bottom line, or actualizing organizational synergy.

    7. Re:Funny, but sickening by Anonymous Coward · · Score: 1, Funny

      I would advise you to get some sense of humour:
      C has been said to be "a language that combines all the elegance and power of assembly language with all the readability and maintainability of assembly language". For some this appears as an issue (usually marketing people, I would say, but there is this sort of people in education also); other people think that good programming style neither could nor should be enforced by the language itself.
      The IOCCC is just another (hilarious) way to state the case.

    8. Re:Funny, but sickening by groomed · · Score: 4, Insightful

      Yes, I suppose, but what does any of that have to do with the IOCCC?

      It's just a competition, and like most competitions, the results are fairly pointless outside the intended domain.

      Reading your rant is like watching a spectator in the Tour de France yell "learn how to drive a car you idiot!" at Lance Armstrong.

    9. Re:Funny, but sickening by Urkki · · Score: 4, Insightful
      • With recursion you get 20 function calls with all their associated overhead. A for loop is a much better solution.

      Except a properly written recursive function, and a loop end up being exactly the same thing once compiled... Even with a C compiler

      Of course anybody putting purposefully obfuscated code into any real software should be shot... All the unpurposefully obfuscated bad code is bad enough, when maintaining it falls on you.

      • You know the shit I'm talking about, jamming all kinds of operations into a for() declaration, badly chosen one-letter variable names, etc..

      That's not the point IMHO, though admittedly a lot of the stuff is just that without any real content. But the real pearls would still be devious to decipher even if all identifier names were clear, and any unnecessary structural obfuscations were written in more clear way.

      • Those suckers never even got their foot in the door. I don't care how smart they think they are, we have to get products out fast, and realistically be able to maintain/upgrade them 10+ years or so.

      You need to lighten up. Some get their kicks from polisihing their car over and over, some get theirs from standing in a river in long ridiculous boots and waving a rod around, and some get it from twisting their brains around a piece of C mumbo jumbo... Nothing wrong with any of that.
    10. Re:Funny, but sickening by RichardX · · Score: 3, Funny

      Just a guess.. but you don't happen to have pointy hair?

      --
      Curiosity was framed. Ignorance killed the cat.
    11. Re:Funny, but sickening by Cygnus78 · · Score: 2, Insightful

      Calm down, it's all about having fun. They do not do this because they want to use it in production code.

    12. Re:Funny, but sickening by Ignignot · · Score: 1

      Some get their kicks from polisihing their car over and over, some get theirs from standing in a river in long ridiculous boots and waving a rod around, and some get it from twisting their brains around a piece of C mumbo jumbo

      I'd say that the C mumbo jumbo also helps them learn about C. Not just what not to do, but different ways to do the same thing. Maybe it makes some code a nightmare, but later on it might be useful. Not to mention that it must help when debugging someone else's code, or adapting it for your own purposes. This is just like some vocabulary games. They aren't useful in and of themselves, but instead they're working out that part of your brain that deals with them. Your brain improves what you use, so this whole obfuscation thing can be considered C training.

      I can just see it now, a cross between Rocky and Hackers where the punk kids trying to Hack the Planet go and train in the Siberian wasteland by writing messed up C code. =D

      --
      I submitted this story last night, and it didn't get posted.
    13. Re:Funny, but sickening by RPoet · · Score: 2, Informative

      Tail call elimination only reduces the amount of stack frames needed. Most of the overhead associated with function calls are still there. That said, recursion is a lot more natural in some types of languages, especially functional ones. And regardless of language, recursion can be much more intuitive and maintainable than imperative loops. Overhead isn't everything.

      --
      "Oppression and harassment is a small price to pay to live in the land of the free." -- Montgomery Burns.
    14. Re:Funny, but sickening by arcanumas · · Score: 3, Informative
      Yeah, i'm sure the guy who wrote this entry is a newbie... :)
      short main[] = {
      277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
      -113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
      14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
      4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
      0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
      4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
      0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
      'p', 072163, 'r', 29303, 29801, 'e'
      };

      Oh, here is the explanation.

      --
      Slashdot Sig. version 0.1alpha. Use at your own risk.
    15. Re:Funny, but sickening by msgregory@earthlink. · · Score: 0, Troll

      All the IOCCC does is make a mockery of the language. C is probably one of the easiest languages to read if written right, as there is very little in the way of obscurities in the syntax compared to many of the more complex languages like C++ and Perl. I'd be more impressed with people who can prove they have the discipline to avoid obfuscations.

    16. Re:Funny, but sickening by MenTaLguY · · Score: 2, Informative

      Except a properly written recursive function, and a loop end up being exactly the same thing once compiled... Even with a C compiler

      The C standard doesn't guarantee optimization tail-recursion; and while gcc does it (to a limited extent), many compilers do not.

      Additionally, it's sometimes important to compile your code without any optimization during debugging.

      Relying on tail recursion is really only possible in languages where the standard guarantees support.

      --

      DNA just wants to be free...
    17. Re:Funny, but sickening by dubious9 · · Score: 4, Insightful

      I'd be more impressed with people who can prove they have the discipline to avoid obfuscations.

      Have you ever read any of the code? Besides formatting, (you can run stuff through indent), this stuff is *very careful* obfuscation. It's not just nonsensical variable names and lack of comments. It's using constructs in novel ways, and comming up with non-trivial solutions to what are quite often complex problems.

      If you can win this contest you know exactly what makes programs hard to read, and thereby in real situations, avoid them. Furthermore, some of the stuff is beautifully arranged and may be faster or more elegant than the easy to read version. It's not a mockery of the language, it's "art in c", and I would happily hire any of the winners as most probably they are masters of the nuances of c.

      --
      Why, o why must the sky fall when I've learned to fly?
    18. Re:Funny, but sickening by legirons · · Score: 1

      "Of course anybody putting purposefully obfuscated code into any real software should be shot.."

      Or re-hired as a consultant when it needs fixing in a hurry...

    19. Re:Funny, but sickening by AchilleTalon · · Score: 1

      You forgot to say we should never drink beer, even if it's free!

      --
      Achille Talon
      Hop!
    20. Re:Funny, but sickening by jaoswald · · Score: 1

      Most languages which have tail-call elimination ALSO have implementations which put effort into making function calls efficient. Basically, the call is reduced to the same jump that your for-loop solution has anyway.

      Whether recursion is "natural" or not depends on the PROBLEM, not the language. Recursion is a natural solution to mapping over a binary tree, for instance. It is the most straightforward solution for factorial and the Fibonacci sequence. You might argue that calculating the Nth member of the Fibonacci sequence is not naturally recursive, although the usual definition of the *sequence* is, because of the extreme redundancy of the computation. (Actually, the Fibonacci sequence is the best example of a recursive solution that is unnaturally inefficient; that's why everyone uses the same example.)

      The ability to express a solution in the natural way, of course, does depend strongly on the language.

    21. Re:Funny, but sickening by Anonymous Coward · · Score: 0

      There isn't a need for him to reveal the company he works for. People like him generally reveal themselves pretty early in the interview process, so are easy to avoid.

    22. Re:Funny, but sickening by msgregory@earthlink. · · Score: 0

      Well, I wasn't trying to say that it doesn't take a lot of effort to code like that. I just think it gives C a bad name to people who don't know C.

    23. Re:Funny, but sickening by UserGoogol · · Score: 1

      I am fairly certain the IOCCC was founded with the explicit purpose of mocking C.

      --
      "Never attribute to malice that which can be adequately explained by stupidity." -- Hanlon's Razor
  14. Transcript by k4_pacific · · Score: 4, Funny

    Here's an excerpt from the award ceremony:

    winner: I won! I won!
    MC: No, you're failing computer science.
    winner: [Segmentation fault]

    --
    Unknown host pong.
  15. Funny about that language by Anonymous Coward · · Score: 0

    What is it with C programmers that they don't just all leave en masse for languages that provide all the power with none of the safety concerns? Even C++ has improved on C's lack of type-safety, buffer checking, and its tendency towards spaghetti code. Better than those two loser languages is Lisp and its decendants which provide hella power without all the cumbersome problems and syntax that C and its cousins suffer from.

    1. Re:Funny about that language by falsifian · · Score: 2, Informative

      Speed. How many programming-language benchmarks are there that don't find C to produce the fastest code, not counting assembly/machine code? For example, interpreted languagues like LISP are completely impractical for something like a raytracer, unless someone makes a miraculously good LISP compiler.

      Also, C is something of a standard language. At least on UNIX-style systems, programs written in any other language have to use some glue-code library to allow them to use standard libraries, system calls, etc. (C++ is close enough to C not to, but I've had a few frustrations with C++ symbols being named differently from C symbols.)

      Anyway, any language that allows you to do everything that C does also allows you to make the same mistakes. Yes, it's probably easier to make them in C than, say... *ducks* Pascal, but it's not an insurmountable problem.

      To be honest, I've never written a C program that required any security, but I hope this helps anyway.

      --
      Each language has its purpose, however humble. -- The Tao of Programming
    2. Re:Funny about that language by Fahrenheit+450 · · Score: 1
      Speed is generally overrated these days -- most programs simply don't need to go 100% hammer-down.

      But if you're still concerned about speed, you can always go with something like OCaml which is just a shade behind C in speed, yet offers you true type saefty, expressiveness, and flexibility all in one package.

      There's been a lot of work done in programming languages over the years, and there are a lot of good languages out there to work with, despite what a glance at the sorely lacking O'Reilly catalog might say...

      --
      -30-
    3. Re:Funny about that language by moebius_4d · · Score: 1

      Lisp isn't generally an interpreted language. Of the major free Lisps, CMUCL and SBCL are compiled and CLISP compiles to byte code. All of the major commercial implementations compile as well.

      Generally Lisp compilers can produce code that runs in the same ballpark, timewise, as C. Here's a perfectly good 3D app written in Lisp: Mirai.

      Personally it's a lot more important to me to be able to write software quickly, with as few bugs as possible, and with pretty good performance. But of course with Lisp once you've written your code you can still annotate it with compiler directives and even use compiler macros to speed up critical parts even more.

      I appreciate your opinion but I would appreciate it even more if you would take the trouble to learn more about things before you disparage them.

    4. Re:Funny about that language by cjellibebi · · Score: 1
      > Speed is generally overrated these days -- most programs simply don't need to go 100% hammer-down.

      Unless you're writing games for mobile phones - especially if writing for a virtual 32-bit processor emulated on an 8-bit physical processor. Ouch!

    5. Re:Funny about that language by falsifian · · Score: 1

      Sorry, I was just trying to pick a super-slow language at random... but now that I think about it, I guess any reasonably popular language will have a fast compiler or an almost-as-fast byte code. Don't get me wrong, I'm no C phanatic. Haskell is my language of choice, compatability permitting. The purpose of my post was to defend C, not to attack other languages.

      --
      Each language has its purpose, however humble. -- The Tao of Programming
    6. Re:Funny about that language by Fahrenheit+450 · · Score: 1

      First reaction: Yech!
      Second reaction: Yeah... that's why I put the word most in my original post. Obviously there are domains where raw speed is paramount; and C and assembly will likely always rule those domains. However, we've reached a point were most apps that people interact with just don't need to go as fast as possible.

      --
      -30-
    7. Re:Funny about that language by moebius_4d · · Score: 1

      No harm, no foul. :)

  16. IOCCC? or IOC-C-C? by TheShadowHawk · · Score: 4, Funny

    Since the Olympics have just finished and still reasonably fresh on my mind, did anyone else read that as a stuttered IOC-C-C? (International Olympic C-C-Committee)

    No? J-J-Just me then?

    --
    Friends don't let Friends use Internet Explorer.
    1. Re:IOCCC? or IOC-C-C? by cjellibebi · · Score: 1
      >International Olympic C-C-Committee

      Sounds like these guys would be the judges if writing C compilers ever became an Olympic event. Pity this wasn't mentioned in the recent poll "Olympic Sports Needed in 2008?".

      I wonder how other Olympic events would benefit from obfuscation. Perhaps all the race-tracks would resemble spaghetti junctions.

  17. Bumper Sticker by pr0nbot · · Score: 3, Funny

    Chucklesome bumper sticker mentioned by someone on Slashdot...

    "Eschew Obfuscation"

    1. Re:Bumper Sticker by Anonymous Coward · · Score: 0

      I don't get it. What's funny about 'Eschew Obfuscation'? Seems like a pretty sensible statement to me.

    2. Re:Bumper Sticker by DMUTPeregrine · · Score: 1

      Sedulously eschew obfuscatory hyperverbosity and prolixity.

      --
      Not a sentence!
  18. Coral Link by TimCrider · · Score: 1

    For all you p2p users out there:

    http://www.ioccc.org.nyud.net:8090/

  19. We get an award, too! by justkarl · · Score: 4, Funny

    And the Lifetime Acheivement in Server Destruction Award goes to...Slashdot!!! Congratulations!

    Seriously, I can practically smell the server melting from here.

    1. Re:We get an award, too! by jbeaupre · · Score: 0, Redundant

      On a serious note, would it be outrageous to suggest Slashdot offer a "cached" page similar to what Google does? Who knows, maybe even use Google's cache. I feel bad for being part of the Slashdot effect (sometimes), but can't resist. A cached page might save somebody grief.

      --
      The world is made by those who show up for the job.
  20. I think we just... by kkovach · · Score: 4, Funny

    obfuscated their webserver. :-)

    - Kevin

    --
    The less confident you are, the more serious you have to act.
  21. Jimmy? by Dreadlord · · Score: 1

    Is it you??

    --
    The IT section color scheme sucks.
  22. Re:More tricks by Bastian · · Score: 5, Interesting

    Recursive calls to main(), if handled with interesting tricks like vectored execution and such, can really spice up a program.

    If you use the trick of storing all of your data in one huge 'array', try to overlap anything you can get away with overlapping. For example, if you have a constant whose most significant byte is the same as the least significant byte in a string, there's not sense in storing that byte twice.

    While not allowed in IOCCC itself, try mixing your C with a language that's even more incomprehensible than C. I had good luck with writing a C program that sent PostScript code to a printer and having all the real work be done in the PostScript code.

  23. Raytracing? by Anonymous Coward · · Score: 1, Funny

    And here I thought the original raytracing algorithms were already pretty heavily obfuscated on their own, hence their rapid adoption throughout the industry.

  24. For those of you who don't want to wait... by jtnishi · · Score: 5, Informative
    For at least one of the entries (Don Yang's, who won the Best Utility category), the code is already up on the internet:

    http://uguu.org/src_rinia_c.html

    The only reason I can even remember where this entry would be is because he's the one a few years ago that won with that strange Saitou-Aku-Soku-Zan combination program. Yeah, I could find utilities to do what his code can do on many other places, but what better way to show your anime fandom & code fanaticism by running something like this instead. ^_^

    1. Re:For those of you who don't want to wait... by fatcow · · Score: 0

      Dude, this guy is a genius! And he really really likes anime. Check out his other work.

  25. In other news... by KoolDude · · Score: 3, Funny


    All prize money for the latest IOCCC have been used up for bandwidth after a %^&*@#@%#^% ( obfuscated ) slashdot effect hit the site soon after results were published. We are sorry for the winners...

    --
    getSexySig(); /* returns sexy signature */
  26. /*Why did I do this*/ by wiredog · · Score: 2, Interesting
    Comment seen in someone else's code just before a block of especially hairy code which, it turned out, used pow() to determine which bits were set in a 16 bit int which was used to hold flags used to determine if certain data was being used. It looked sort of like:

    while(pow(something,16)==n)
    {
    if(something)
    {
    for(something else)
    {
    ...

    This was on an embedded system where using one 16 bit int instead of 16 8-bit chars to hold the flags resulted in a vital savings of memory.

    1. Re:/*Why did I do this*/ by red+floyd · · Score: 1

      Embedded code seen in actual system:

      char *s; //...
      while (strncmp(s," ") == 0)
      s++;

      --
      The only reason we have the rights we have is that people just like us died to gain those rights. -- Cheerio Boy
    2. Re:/*Why did I do this*/ by red+floyd · · Score: 1

      Shit. That should have been:

      while (strncmp(s," ",1) == 0)
      s++;

      --
      The only reason we have the rights we have is that people just like us died to gain those rights. -- Cheerio Boy
    3. Re:/*Why did I do this*/ by Anonymous Coward · · Score: 0

      How do you use pow() to determine which bits were set in a 16 bit int?

  27. You should try Pascal instead of C by mangu · · Score: 1, Insightful
    If you think "if (year%4 == 0) { days_in_feb=29; }" is easier to read and understand at a glance than "if (!(year%4)) { days_in_feb=29; }" then the easiest for you to understand would be:


    if (year mod 4) = 0

    then

    days_in_feb := 29;

    endif

    or something like that, it has been 20+ years since I last wrote Pascal, I'm not so familiar with the syntax anymore. Or try COBOL for the true detailed syntax you seem to adore. But one of the many advantages of C that make it so great is the concise syntax. After reading a few millions of lines of code, one gets tired from so much redundancy. If you really have experience with C, things like treating integers as boolean have become second nature.

    I suggest that you trust your programmers more. The fact that you have problems understanding C code means that you should concentrate on management, rather than trying to micro-manage programmers.

  28. So that's why I don't hear back by Anonymous Coward · · Score: 0

    from those job ads that post a little programming exercises for you to submit a solution too.

    1. Re:So that's why I don't hear back by Anonymous Coward · · Score: 0

      Or perhaps because the job description includes "excellent communication skills" and you can't write for shit?

  29. Re:More tricks by Peter+Cooper · · Score: 1

    I recall reading an article about how Gates and Allen developed the first Microsoft BASIC, and that they had to use one of those tricks to get it into the required space.

    So, for example, if the most significant byte of a single command was shared with the least significant byte of another.. they could jump into the middle of another instruction. Crazy.

  30. missing the point by Speare · · Score: 2, Insightful

    Anyone can write unreadable code.

    It takes an artist to write code that is both unreadable and beautiful at the same time.

    If your entry isn't beautiful, you're just a bad programmer.

    --
    [ .sig file not found ]
    1. Re:missing the point by Bisqwit · · Score: 1

      So it's the same as with abstract/surreal art?

  31. You've passed over many good people then... by rarose · · Score: 4, Insightful

    Those suckers never even got their foot in the door. I don't care how smart they think they are, we have to get products out fast, and realistically be able to maintain/upgrade them 10+ years or so.

    At a couple of the companies I've been with we'd have after-hours informal little "Who can optimize this code the most" contests and they were amazingly instructive. They force you to think about solutions in new and creative ways, and to really understand an algorithm or CPU at a far deeper level than a simple straightforward implementation.

    And while those obscenely optimized implementations may never get near the shipping product, you always walk away with a far far better grasp of how the shipping code really does work. (And yes, we've discovered bugs by inspection... because the little optimization contest had us questioning assumptions that the shipping code relied upon)

    --
    --Rob
    1. Re:You've passed over many good people then... by TeknoHog · · Score: 1
      At a couple of the companies I've been with we'd have after-hours informal little "Who can optimize this code the most"

      Hence your sig, I presume :)

      --
      Escher was the first MC and Giger invented the HR department.
  32. checking for leap years by ghum · · Score: 1

    year modulo 4 fails ... there are quite some exceptions to this simple rool. Not caring for them makes programms fail very seldom, and give QC a hart time.

    in Python it is as simple as


    import calendar
    if calendar.isleap(year):
  33. More C-related sillyness by cjellibebi · · Score: 2, Funny

    Slightly offtopic, but this will serve the needs of those of us reading this thread for a fix of C-related humour. The Infrequently asked questions in C (C-IAQ)

  34. Beaten to it by SilentJ_PDX · · Score: 1

    Jean-Louis Gassee beat to you that 11 years ago...

  35. Bad example by Anonymous Coward · · Score: 0

    Since Lance Armstrong is also a pitch man for Subaru, he'd better know how to drive a car.

  36. Thank God! by Anonymous Coward · · Score: 0

    I've heard several of the winners were based on ASCII-art Goatse.

  37. Re:More tricks by jericho4.0 · · Score: 1
    It's a much ignored fact the Gates was a good programmer.

    One of the craziest hacks I've heard of was in an article by this guy who was hired to make some changes to an early calculator design. The calculator used a spinning magnetic drum for storage, a head that could read and write at the same time, and a buffer. It seems the original designer had extended the working memory of the machine by reading the 'OS' into the buffer while the head wrote data. The calculation would then have to finish in one revolution of the drum so the head could write it back in time for the execute loop to read it. This was all written in assembly with zero documentaion. It's generally considered a Bad Idea to store your boot RAM in a serial buffer.

    --
    "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
  38. Thats not obsfucated by Anonymous Coward · · Score: 0

    That's just stupid.

    1. Re:Thats not obsfucated by red+floyd · · Score: 1

      Oh yeah, I agree. I looked at this and just laughed my head off. I couldn't even modify it because it was third-party certified, and this was for a DoD project.

      And this was in code for mission critical stuff too. There was a lot of other crap there... I wrote up about 7 problem reports and routed them to the developers contact, the program office, my management, etc...

      --
      The only reason we have the rights we have is that people just like us died to gain those rights. -- Cheerio Boy
  39. Re:More tricks by Anonymous Coward · · Score: 0

    It sounds like you are talking about The story of Mel.

  40. Re:More tricks by Bastian · · Score: 2, Interesting

    While a lot of stuff folks did back in the day, a lot of times there wasn't much choice. If you don't have enough (memory | speed) to accomplish the task at hand, you'll start resorting to ugly hacks. There are some interesting articles out there on all the horrible things programmers did to old game systems like the Atari 2600 and the Intellivision that would be considered Hateful today but were necessary to create a lot of good games at the time.

    The real problem is lack of documentation, and it's a problem to this day, especially when a programmer is working on a project alone. I know I'm guilty. You should take a look at some of the code I've been writing in the past week. It's like I couldn't put two slashes together to save my life.

  41. IOCCC mirrors needed by chongo · · Score: 4, Informative
    When we release the IOCCC winners, we are going to need more mirrors. If you want to mirror the IOCCC, please send EMail to Simon Cooper at:

    mirror-request at ioccc dot org

    Please include the following words in the subject of your EMail message:

    IOCCC 2004

    We will ask you a few questions and provide you with information on how we would prefer you to mirror the site. Please don't start mirroring until we have responded and processed your mirror request. Thanks in advance for your willingness to help.

    --
    chongo (was here) /\oo/\
  42. My historical favorite by Anonymous Coward · · Score: 0

    #include "/dev/tty"

  43. IOCCC - FAQ and History by chongo · · Score: 2, Informative
    Several people have asked / wondered what the International Obfuscated Code Content was all about, how it got start, etc.

    Definition

    Obfuscate: tr.v. -cated, -cating, -cates. 1. a. To render obscure. b. To darken. 2. To confuse: his emotions obfuscated his judgment. [LLat. obfuscare, to darken : ob(intensive) + Lat. fuscare, to darken < fuscus, dark.] -obfuscation n. obfuscatory adj.

    Goals:

    • To write the most Obscure/Obfuscated C program under the content 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. :-)

    And here is one entry from the IOCCC FAQ that talks about how the IOCCC got started:

    One day (23 March 1984 to be exact), back Larry Bassel and I (

    Landon Curt Noll) were working for National Semiconductor's Genix porting group, we were both in our offices trying to fix some very broken code. Larry had been trying to fix a bug in the classic Bourne shell (C code #defined to death to sort of look like Algol) and I had been working on the finger program from early BSD (a bug ridden finger implementation to be sure). We happened to both wander (at the same time) out to the hallway in Building 7C to clear our heads.

    We began to compare notes: ''You won't believe the code I am trying to fix''. And: ''Well you cannot imagine the brain damage level of the code I'm trying to fix''. As well as: ''It more than bad code, the author really had to try to make it this bad!''.

    After a few minutes we wandered back into my office where I posted a flame to net.lang.c inviting people to try and out obfuscate the UN*X source code we had just been working on.

    BTW: I (Landon Curt Noll) had to post this

    typo correction. Thus began the tradition of putting typos in the contest rules and guidelines ... to make them more obfuscated of course! :-)

    BTW: This posting was made back in the days when AT&T was the evil giant. Now, Microsoft makes AT&T look mild and kind in comparison. :-( (IMHO) ).

    BTW: See the story about the '' Bill Gates'' award. :-)

    OK, back to the story. We (Larry and I) received a number of entries by EMail. When we began to receive messages from outside of the US, Larry and I decided to include International in the name. The 1st IOCCC winners were posted on 17 April 1984.

    There were 4 winners in 1984:

    <dis>honorable mention

    --
    chongo (was here) /\oo/\
  44. Code Was Supposed to Be Up Today by darkonc · · Score: 2, Informative
    According to the page, the actual code for the wineners should be up mid-October.

    They intended to have the winning code available today, but the website was designed by last year's winner, and they're guessing it'll take another 6 weeks to figure it out.

    They started in January.

    --
    Sometimes boldness is in fashion. Sometimes only the brave will be bold.
  45. Good example by Fenris+Ulf · · Score: 1
    Since Lance Armstrong is also a pitch man for Subaru, he'd better know how to drive a car.
    Winners of the IOCCC are expert C coders who can also write very elegant and readable code, so the example still stands.
  46. This is *not* ovuscation by darkonc · · Score: 2, Interesting
    The following code is not obfuscation. It's an honest attempt to split a Red Hat RPM filename into product and version.

    while($rpm=<>){ chomp $rpm;
    if( $rpm =~ s/-((?!(g77|8514|gui)-)(([0-9][-.0-9]*)?_?(?!X11)( (?i)trunk|[abix]|horde|alpha|stable|cvs|beta|gamma ))?[-_.0-9]*(([a-zZ]|([0-9]*(svn|fc|EL|FIT|FC|x|fi nal|rh|ii|pl|tp|horde|fcs|rc|pre)))[-.0-9]*)?)\.(s rc|noarch|i[3456]86).rpm//){;
    printf "name=%23s \t vers=%s\n",$rpm, $1;
    }else{ print "ugh!\n" };
    }
    Remember to remove the whitespace from the regex before running it.
    --
    Sometimes boldness is in fashion. Sometimes only the brave will be bold.
    1. Re:This is *not* ovuscation by ameoba · · Score: 1

      1) You're using Perl.

      2) You're using a regex.

      I can't really compete with that.

      --
      my sig's at the bottom of the page.
  47. identifying leap years by MenTaLguY · · Score: 1
    Just for reference, lest you be bitten by this sometime in the future, the correct method for identifying a leap year is:
    ( ( year % 4 ) == 0 ) && ( ( year % 100 ) != 0 ) || ( ( year % 400 ) == 0 )
    (e.g. 2000, 2004 and 1600 are leap years; 1900 and 2100 are not)
    --

    DNA just wants to be free...
  48. god you're dumb by Anonymous Coward · · Score: 0

    I pray i never work for anyone as dumb as you.

  49. Only joking ;) by Anonymous Coward · · Score: 0

    #include
    #define ja 0x6B
    #define s "%s%c%c%c\n"
    #define tr "su"
    #define at 0143
    #define kt 's'

    int main(void) { printf( s,tr,at,ja,kt ); }

    1. Re:Only joking ;) by Anonymous Coward · · Score: 0

      errr:
      #include <stdio.h>

      I forgot to hit preview... idiot!

  50. Re:More tricks by jonadab · · Score: 1

    I've found that bringing in alien paradigms can be effective. For example, if
    you're writing in C, simulate functional programming mechanisms, such as
    closures. This by itself is not enough, because someone could be reading the
    code who knows Scheme, but it is nonetheless effective, because it will throw
    a significant portion of your audience into unmitigated confusion. Only people
    familiar with the alien paradigm will even have a *chance* at understanding
    what the code is doing.

    --
    Cut that out, or I will ship you to Norilsk in a box.
  51. Re:More tricks by Bastian · · Score: 1

    No wonder some folks complain about GTK and Perl.

    =D

    Really, I didn't even really have a good idea of what a closure was until I learned to use them in Perl. It just seemed natural in Scheme. Sort of like how I didn't really understand certain parts of English grammar until I started learning other languages, even though I could use them fluently.

  52. Uh, mods... by Anonymous Coward · · Score: 1, Informative

    This isn't informative - it's a joke.

  53. Re:More tricks by Anonymous Coward · · Score: 0

    I know people who talked to Billy when he was still answering the phones at MS. They learned to never report a bug to him because he would fix it and add in more. The rumors about him being good are all a result of people who he made lots of money knowing when to say nice things about people even if they are little white lies.