Slashdot Mirror


The IOCCC Competition Is Back

Rui Lopes writes "After a 5 year hiatus, the IOCCC (International Obfuscated C Code Contest) is back! This marks the 20th edition of the contest. Submissions are open between 12-Nov-2011 11:00 UTC and 12-Jan-2012 12:12 UTC. Don't forget to check this year's rules and guidelines."

36 of 201 comments (clear)

  1. It'd be nice if ... by fsckmnky · · Score: 5, Insightful

    They created a competition for the most well structured, well documented, clean and correct code.

    Most C coders seem to achieve obfuscation without any additional incentive.

    1. Re:It'd be nice if ... by phantomfive · · Score: 5, Interesting

      But then we never would have a piece of code that calculates its own area. Isn't that worth it? (LINK).

      --
      "First they came for the slanderers and i said nothing."
    2. Re:It'd be nice if ... by masternerdguy · · Score: 5, Insightful

      This is a good competition because it helps exploit the guts of C in new and exciting ways. Go back to your clean and neat database client if you can't play with the cowboys.

      --
      To offset political mods, replace Flamebait with Insightful.
    3. Re:It'd be nice if ... by Hazel+Bergeron · · Score: 5, Insightful

      Most C coders seem to achieve obfuscation without any additional incentive.

      Nonsense. C is simple and, while some smart programmers think it's necessary to over-use the preprocessor (even the Linux kernel is sometimes guilty), it's a language you can learn once and apply productively for the rest of your life.

      Contrast this with the ten dozen other fly-by-night half-baked languages which have flooded the marketplace over the past year, each with their uninteresting quirks of syntactic sugar, competing on the basis of some uniquely uninteresting difference which can almost always be trivially implemented in any of the alternatives. They are hard to read in the same way that German is hard to read to someone who has only been reading German for a year: skill and speed comes through practice with the language, not from the ego of its authors.

    4. Re:It'd be nice if ... by Anonymous Coward · · Score: 5, Funny

      Yeah, Python sure flooded the marketplace in the past year. Now, if you'll excuse me, I've got to check the breaking news about the Lewinsky scandal after buying some hot dot-com stocks while on the way to work at the World Trade Center because apparently it's the late nineties again somehow.

    5. Re:It'd be nice if ... by Anonymous Coward · · Score: 5, Insightful

      Nonsense. C is simple and, while some smart programmers think it's necessary to over-use the preprocessor (even the Linux kernel is sometimes guilty), it's a language you can learn once and apply productively for the rest of your life.

      Contrast this with the ten dozen other fly-by-night half-baked languages which have flooded the marketplace over the past year, each with their uninteresting quirks of syntactic sugar, competing on the basis of some uniquely uninteresting difference which can almost always be trivially implemented in any of the alternatives. They are hard to read in the same way that German is hard to read to someone who has only been reading German for a year: skill and speed comes through practice with the language, not from the ego of its authors.

      +1, it all started going downhill when :
      - professional language designers abdicated their role, and the void was filled by amateurs
      - people who use these languages have no fucking clue what they're doing and we're all paying the price
      - corporations hyped languages for their own purposes and languages stagnated or worse were crapified to an absurd level (witness java).

    6. Re:It'd be nice if ... by Rosco+P.+Coltrane · · Score: 4, Interesting

      Most C coders seem to achieve obfuscation without any additional incentive.

      You got it wrong: bad coders create bad code. Good coders know how to create good code. In any language.

      When someone knows C well enough to create a truly obfuscated or compressed piece of portable C code that follows the rule of the language to a tee, i.e. that can be compiled strict or linted, and wins the IOCCC, it's a very good sign that this someone can create excellent C code.

      I should know, I won the IOCCC years ago, and used it many times in my resume. When would-be employers told me "what's the IOCCC?", I knew they weren't going to be good employers. When they told me "oh, I see you won the IOCCC", they knew I could code good C, and I knew they groked what I did. Winning the IOCCC helped me land a job a few times.

      --
      "A door is what a dog is perpetually on the wrong side of" - Ogden Nash
    7. Re:It'd be nice if ... by tgv · · Score: 3, Insightful

      Sure, that could be nice as well, but the IOCCC provides great challenges and puzzles, something that a clean code contest wouldn't. And what would you rather see in your news paper: difficult puzzles or easy ones? Or, for the youngsters here: would you rather play word feud, or type the answer to 1 + 1 over and over again?

      Besides that, the IOCCC entries contain mostly well structured and correct code, and afterwards they get documented as well. It's just not readable.

    8. Re:It'd be nice if ... by 93+Escort+Wagon · · Score: 3, Funny

      Nonsense. C is simple and, while some smart programmers think it's necessary to over-use the preprocessor (even the Linux kernel is sometimes guilty), it's a language you can learn once and apply productively for the rest of your life.

      Contrast this with the ten dozen other fly-by-night half-baked languages which have flooded the marketplace over the past year, each with their uninteresting quirks of syntactic sugar, competing on the basis of some uniquely uninteresting difference which can almost always be trivially implemented in any of the alternatives. They are hard to read in the same way that German is hard to read to someone who has only been reading German for a year: skill and speed comes through practice with the language, not from the ego of its authors.

      Wow! Dr. Ritchie, everyone thought you were dead!

      --
      #DeleteChrome
    9. Re:It'd be nice if ... by Anonymous Coward · · Score: 4, Insightful

      Closed source code is the same, only you don't get to see it.

    10. Re:It'd be nice if ... by Rosco+P.+Coltrane · · Score: 4, Informative

      Maybe I'm a little older than you think? :)

      --
      "A door is what a dog is perpetually on the wrong side of" - Ogden Nash
    11. Re:It'd be nice if ... by petes_PoV · · Score: 4, Insightful

      Nonsense. C is simple and, while some smart programmers think it's necessary to over-use the preprocessor (even the Linux kernel is sometimes guilty), it's a language you can learn once and apply productively for the rest of your life.

      Contrast this with the ten dozen other fly-by-night half-baked languages which have flooded the marketplace over the past year.

      This clearly shows you simply don't understand the problem. A good programmer can (and does) write well structured, clean, DOCUMENTED and maintainable product in any language. The issue has nothing to do with the language used and everything to do with lack of discipline, inexperience and a slapdash and unprofessional attitude. Usually the worst programmers are the ones who think that once the code is written and compiles clean, the job is done. For most of these people there is little hope of educating them as they are incapable of seeing the bigger picture.

      --
      politicians are like babies' nappies: they should both be changed regularly and for the same reasons
    12. Re:It'd be nice if ... by martin-boundary · · Score: 3, Funny

      Great Scott! You're in a TIME LOOP! Don't move! There's a car to your left, get in slowly and accelerate to 88mph down the street. Oh, and here's a banana peel for the FUSION REACTOR.

    13. Re:It'd be nice if ... by Anonymous Coward · · Score: 4, Interesting

      You're making basically the same argument as people were saying back when machine code was what people wrote and C was new. If you have an open mind, you can easily see that C has serious shortcomings by modern language standards.

      C offers no abstractions for complex data types. It offers no subtyping. There's no facility for generic programming other than macros, which everyone knows suck. No support for closures or comprehensions. None of these things are "trivially implemented", as you state. Even its syntax sucks, as anyone would agree who's tried to declare a non-trivial function pointer.

      Many common programming tasks require extensive pointer manipulation in C. Even the best programmers (I'm one of them, and I concede this point) make ocassional mistakes with pointers, and they are the worst kind of bug: silently incorrect or a crash at a random place in the code.

      C is perfectly appropriate for some projects, especially with really low-level code (as most C constructs translate directly to assembly). C++ is usually better, as it has a richer typing system and ability to do generic programming, but you need to be an expert as the language is full of pitfalls (which are mostly C's fault). For projects that don't need to be close to the hardware, scripting languages can multiply programmer productivity.

    14. Re:It'd be nice if ... by gomiam · · Score: 3, Funny
      I would suggest you take up dubbing the Twilight movie series. You seem to have half their dialogues pat down.

      Back on track, do you have anything useful to add besides pining for the fjords?

    15. Re:It'd be nice if ... by antifoidulus · · Score: 3, Insightful

      while some smart programmers think it's necessary to over-use the preprocessor

      And that is ultimately my main beef with C, it's impossible to write non-trivial code that DOESNT make use of the pre-processor. Header guards in 2011? Really? C either needs to make an Objective-c like import statement a standard or else make #pragma once standard and make it default, so that if in the rare case you do actually need to include a file more than once, THEN you have to use a pre-processor command. I think the pre-processor is a really useful feature of C, but it should never be essentially mandatory to use it.

    16. Re:It'd be nice if ... by Austerity+Empowers · · Score: 3, Funny

      Java is NOT an upgrade to C++. There was a fork in the road, to the left went C++ to the right went Java. C++ took you through a swamp filled with poisonous snakes, quicksand and man eating spiders. Java took you through a haunted forest, with werewolves and zombies.

      No matter which path you took, you died before reaching your goal.

    17. Re:It'd be nice if ... by phantomfive · · Score: 5, Informative

      Many common programming tasks require extensive pointer manipulation in C. Even the best programmers (I'm one of them, and I concede this point)

      I'm seriously doubting your professed skill here. You don't ever have to do pointer arithmetic in C, unless you are counting parameter passing as 'extensive pointer manipulation,' but you pass parameters as pointers in Java too (that's why you can get an NPE). The most common use of pointer arithmetic is for array processing, but if you want to be safe you can just use the array[] notation and not worry about understanding pointer arithmetic (I usually do, unless I have a compelling need to use pointer arithmetic). Furthermore I don't even know what you are talking about when you say, "non-trivial function pointer." Aren't all function pointers the same, just a bunch of parameters and a return value? Or are you declaring an array of function pointers or something? That might be where your problems are coming from.

      From experience I can say by far the thing that takes the most extra time when I am writing in C (compared to Java) is the lack of a good library, with common data structures like hash tables and lists and regular expressions. The number of times I've had to write a generic list library for some random platform, or figure out someone else's nonstandard implementation, is depressing.

      Also the generics in Java are a double edged sword. They allow more flexibility, but allow you to get away with writing incredibly confusing code, that can be extremely difficult to understand without a debugger. C code (really) tends to be a lot more readable. The downside is that it's usually a lot easier to refactor Java code without needing to rewrite a lot of interfaces (even when the interfaces were poorly written in the first place).

      Ultimately though, a good programmer will write good code in any language. A poor programmer will likewise write poor code in any language.

      --
      "First they came for the slanderers and i said nothing."
    18. Re:It'd be nice if ... by shutdown+-p+now · · Score: 3, Insightful

      It's "broken" in a sense that, if you try real hard to break it, you can find ridiculous corner cases that can do that. In the meantime, there are millions of line of C and C++ code written using it, which compile and work just fine.

    19. Re:It'd be nice if ... by BenoitRen · · Score: 3, Interesting

      Haven't you noticed how every cross-platform C/C++ library starts out with pages of pages of "MY_LIBRARY_INT32" and "MY_LIBRARY_EXPORT" and other redefinitions of "standard" types, keywords, and functions? That's because C is a badly designed language where the behaviour and/or availability of even basic language keywords like "int" is a crap shoot that depends on the compiler and the target processor type

      Well, duh. That's the entire point of C. You're complaining that it's a language close to the metal.

      Still, since C99 there are special integer types available that define exactly how large they are and if they're unsigned or not. Yes, they are widely available. It's been over 10 years since their introduction.

      Meanwhile, this Java code will work on all platforms, processors, and compilers, forever and ever:

      At least until Java decides to deprecate parts of its standard library. Java code written during the 90s no longer works. So much for "write once".

  2. Underhanded C contest should return by vadim_t · · Score: 5, Interesting

    The IOCCC is cool, but the Underhanded C Contest was a lot more valuable.

    The entries for the IOCCC can show a lot of cleverness, but nobody in their right mind would accept such code. The beauty of the Underhanded C ones is that the code looks reasonable, but does extremely undesirable things.

    1. Re:Underhanded C contest should return by Truekaiser · · Score: 3, Interesting

      call me paranoid but this contest and the ioccc are the reasons why i don't particularly let anything from s.e.l. touch my systems. i am not a good enough coder to be able to tell if what it's doing is what it says it's doing or something the cia wants it to do..

    2. Re:Underhanded C contest should return by martin-boundary · · Score: 5, Insightful

      Then you should read Ken Thompson on putting backdoors in C compilers. Do you trust your build system?

  3. Re:I would like to see this rule illustrated by Anonymous Coward · · Score: 4, Insightful

    Look up "Duff's Device". There's a good example.

  4. Awesome! by Anonymous Coward · · Score: 4, Funny

    It's about time I got some more reference code.

  5. Re:Use Duff's Device by JonySuede · · Score: 5, Interesting

    don't use them anymore, go read that post: http://lkml.indiana.edu/hypermail/linux/kernel/0008.2/0171.html

    --
    Jehovah be praised, Oracle was not selected
  6. Re:Use Duff's Device by Anonymous Coward · · Score: 5, Interesting

    Jim Gettys has a wonderful explanation of this effect in the X server. It turns out that with branch predictions and the relative speed of CPU vs. memory changing over the past decade, loop unrolling is pretty much pointless. In fact, by eliminating all instances of Duff's Device from the XFree86 4.0 server, the server shrunk in size by _half_ _a_ _megabyte_ (!!!), and was faster to boot, because the elimination of all that excess code meant that the X server wasn't thrashing the cache lines as much.

    Emphasis mine. That's REALLY freaking interesting. Posting this AC before modding you up.

  7. The Internet is based on C by Required+Snark · · Score: 5, Insightful
    I find all the "C sucks" comments to be both amusing and stupid. Without C code there would literally be no Internet. Every bit you are sending and receiving uses C. The two operating systems that represent 99.99% or more of the running computers that are online run C. Both Windows and Linux use the BSD TCP/IP stack.

    If C did not get the job done for this kind of computing then it would have been replaced. The fact that C thrives in the systems programming domain is a tribute to it's utility.

    A proficient C coder can write clear, maintainable, efficient code that runs on many platforms. This requires both skill and practice. Not everyone is capable of doing this. It requires the ability to keep multiple competing abstractions in mind when coding. I think a lot of people try this and find it difficult and then blame the language. Those who persevere and learn this style of working can usually move on to other kinds of programming and also do excellent work.

    Some problem domains require different languages and different skill sets. Personally, I like writing code where I know that if I were to look at the assembly code generated by the compiler I can see how it relates to the C code I wrote. I rarely do this, but it's good to know that I can if I want to. I'm doing any C coding now, because I always use the appropriate language to the task. But I also know that my C coding skills give me a distinct advantage in solving difficult problems, no matter what they are,

    --
    Why is Snark Required?
    1. Re:The Internet is based on C by Sduic · · Score: 5, Interesting

      Without C code there would literally be no Internet.

      Because obviously only C is Turing-complete.

      Before I stir up any vitriol, I'm just kidding. I think C is under appreciated precisely because is provides only a thin abstraction that (hopefully) maps well to the target architecture, but otherwise stays out of the way. That is to say, when all you have is a hammer, you can easily shoot yourself in the foot.

      --
      *this space intentionally left blank
      "One of the four pointers saying 'come and see', and I saw, and beheld a white
    2. Re:The Internet is based on C by dlgeek · · Score: 3, Informative

      #include
      uint16_t x = 0; /*unsigned 16 bit integer */
      int32_t y = 0; /*signed 32 bit integer */

      Almost every platform I've ever worked on has stdint...

    3. Re:The Internet is based on C by mdf356 · · Score: 3, Insightful

      stdint.h came in with C99. There were decades where people hand-rolled their own versions so network communications would work...

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    4. Re:The Internet is based on C by mdf356 · · Score: 5, Informative

      - I think people who put the "*" of pointer syntax near the variable name and not the type name when declaring pointers should be shot. It should always be int* pointer_to_int, not int *pointer_to_int.

      I'm sure my complaints are unwarranted except for the first point.

      But that's backwards of what the compiler really does. Consider this:

      int* p, q;

      What types do p and q have? p is a pointer-to-int; q is an int. By putting the * next to the type name it makes it look like all the things are int*, but they're not. By putting the * with the type (which I did for my first year of C coding) you're making reading the code harder rather than easier. It'd be like writing

      a = b * c+d;

      and trying to convey that the '+' binds tighter since it doesn't have spaces. That's not what the compiler will do and writing it so only serves to confuse the reader.

      In addition, what you see at declaration is representative (modulo the weirdness of array subscript and pointer deference) to what you'd do to get the type. That is, int ***p means that you'd have to type ***p to get an int. *p means you'd need another ** to get an int, etc.

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    5. Re:The Internet is based on C by martin-boundary · · Score: 3, Insightful
      Nonsense. Windows security flaws have historically been due to boneheaded design decisions. Windows was never meant to run as a node on the internet, that functionality was retrofitted when Bill decided to do his famous 180 about turn on the computer highway because he'd missed the internet on-ramp. "Security" was retrofitted ten years later.

      Problems with the C standard library certainly do exist and can expose security issues, but Windows security problems exist because the OS design emphasises user friendliness and backwards compatibility over tight protections.

      It's like inside your home, you don't lock all your cupboards, drawers and doors - that would be painful, eg to walk from the kitchen to the living room you'd take out your key, unlock the door, open go through shut, relock the door, each time. To make your home livable you keep it insecure, and that's how Windows was designed from the ground up.

      But now suppose there's a magic internet wormhole that opens in your toilet room, and anybody can enter your house. Suddenly it makes sense to have locks on all the doors and cupboards etc, but it's too late. Windows + Internet = insecure.

      Unix doesn't have this problem, because Unix was always designed as a hotel (multiuser OS) rather than a home. So there's locks on the rooms and the swimming pool needs an access card etc. If a wormhole opens in the hotel lobby or even in one of the guest rooms, there's limited access to most areas by design.

  8. Re:Use Duff's Device by TheRaven64 · · Score: 4, Insightful

    It's the main reason why C++ does well in microbenchmarks and does so much worse in real-world usage. It encourages a lot of inlining, which reduces branching but increases instruction cache usage. It's difficult to benchmark well, because instruction cache pressure changes over time depending on what else is happening with the system.

    --
    I am TheRaven on Soylent News
  9. Because D is such a heavily used language... by Anonymous Coward · · Score: 5, Insightful

    A number of quick points... Some people just don't know, so here are some practical speaking points...

    -C has been around longer than most of the non-C programmers alive. That includes you people on this site, which has the smartest people, from one of the most divisive areas in the civil space: the "tech wars".

    -D was such a better language... also, C++ because we never hear about C anymore.

    -Java is on it's way out, being deprecated by the largest company in the world, which also deprecated Flash (on mobile) which Adobe just acquiesced to, replaced by Google's new iteration. Maybe not in the next 5 years, but it can no longer grow... it will have to get smaller with less support.

    -Objective-C, used by Apple Inc., the largest company in the world, is a wholly-compatible superset of (ANSI) C. There are no signs of change here. Big surprise, it's all the same hardware components, just in larger capacities, at faster rates, and smaller form-factor. C can't help us with the flux capacitor... but that has not been added to the standard CPU, memory, memory storage, etc. model.

    -Google announced that Android will run a C-like-language in the native space that uses the CPU and GPU. Even with Dart coming our way...

    -CUDA... C is relevant in other (all) GPU spaces which is the go-to-guy, for the moment, to eak out more performance from a machine.

    -And here is where the feelings get hurt: In college, I strattled the EE/CS line while being firmly EE. EEs learn C because it teaches them valuable things about the hardware, being a very light obfuscation. CS departments tend to concentrate on, well, anything else. Flavors of the year, interesting projects, etc. That is their place. My older brother went the CS route, 8 years before I got my turn and went EE. I admire him and his success greatly but I know, push came to shove, I can talk about certain topics without talking about garbage collectors and universal typing.

    So, please, if you've never used C in any significant way, just don't comment. Listen. People, young and old, have something to tell you about the most significant programming language ever invented.

    And to bring this all together: When you are trying to eke out CPU cycles so your 3D rendering is above 60 fps on that mobile device, you will know why closeness to hardware and C, in particular, may be your best friend. Or a C-like language...

    Another way to look at it: People who know C and have worked with it, can't just unknown it. They know what you non-C people know, but also have other experience. If MOST of them say C is indispensable, then how about you do the one thing some Tech Asshole never do: Take someone else's advice. And STFU.

    Can we just talk about something else that is awesome and not caught up in this stupid argument?

    1. Re:Because D is such a heavily used language... by Anonymous Coward · · Score: 3, Funny

      People, young and old, have something to tell you about the most significant programming language ever invented.

      You mean LISP? I haven't seen anyone mention it yet.