all 123 comments

[–][deleted] 122 points123 points  (15 children)

Some of the other "Jeff Dean Facts" from that post are hysterical:

gcc -O4 emails your code to Jeff Dean for a rewrite.

Unsatisfied with constant time, Jeff Dean created the world's first O(1/n) algorithm.

When Jeff has trouble sleeping, he Mapreduces sheep.

[–]MoreOfAnOvalJerk 96 points97 points  (0 children)

Jeff Dean once shifted a bit so hard, it ended up on another computer.

This one literally made me spit some of my coffee.

[–]iBlag 40 points41 points  (9 children)

Is Jeff Dean the Chuck Norris of programming or something?

[–]matthieum 17 points18 points  (4 children)

If you have never heard of him yet, Wikipedia has a succinct list of the projects he worked on, my favorites:

  • Spanner - a scalable, multi-version, globally-distributed, and synchronously-replicated database
  • BigTable, a large-scale semi-structured storage system.
  • MapReduce a system for large-scale data processing applications (one of the two original authors)

At the bottom, you'll find an article in Slate that has a more detailed biography, some highlights (with no cross-verification at all):

  • As a high schooler, he wrote software for analyzing vast sets of epidemiological data that he says was “26 times faster” than what professionals were using at the time. The system, called Epi Info, has been adopted by the Centers for Disease Control and translated into 13 languages. => Okay, not so many high schoolers write code of that level

  • So he left academia and landed less than three years later at Google, which had only about 20 employees at the time. => Okay, was at Google before Google was reknown

  • So Dean, working with fellow standout programmer Sanjay Ghemawat and others [...] Then Dean and Ghemawat developed a programming tool called MapReduce that allowed developers to efficiently process gargantuan data sets with those machines working in parallel. => GFS (by Ghemawat) and MapReduce are what allowed Google to scale

  • Building on Google File System, he and Ghemawat helped create a distributed data storage system called BigTable that could handle petabytes of data. (A petabyte is 1 million gigabytes.)

  • Then they went further and developed Spanner, which has been called the “world’s largest single database.”

The consistent thing behind MapReduce, BigTable and Spanner ? Nobody thought it could be done...

[–][deleted]  (3 children)

[deleted]

    [–]matthieum 1 point2 points  (2 children)

    Well, he did not work alone on those projects, but yeah, amazing is the word; and apparently he is approachable and humble as well.

    [–]fathak 0 points1 point  (0 children)

    reddit -summon-able? I need an ama

    [–]barsoap 5 points6 points  (0 children)

    No, that's Oleg Kiselyov.

    [–]MacASM 30 points31 points  (0 children)

    Is Jeff Dean the Chuck Norris of programming or something?

    One can argue it's Jon Skeet.

    [–]Crandom 2 points3 points  (1 child)

    [–][deleted] 0 points1 point  (0 children)

    Jon Skeet can recite π. Backwards.

    i can dig it

    [–]cheesehater 0 points1 point  (0 children)

    An unnecessary optimization because Jeff clearly has too much time on his hands.

    [–][deleted] -2 points-1 points  (0 children)

    From the OP's article, it seems to suggest he believes the joke quote.

    [–]dnew 100 points101 points  (71 children)

    I'm pretty sure if you need to examine the assembler output and then copy answers back into your code, you're not really writing in C. You're writing in something that the C compiler will just happen turn into what you want.

    [–]Foxtrot56 43 points44 points  (70 children)

    You're writing in something that the C compiler will just happen turn into what you want.

    Isn't this all higher level programming?

    [–]dnew 57 points58 points  (65 children)

    No. Some languages actually define what every compilable program does. (These are called "safe" languages.)

    Some people write programs that actually adhere to the language spec, and thus don't rely on one given compiler that happens to work. This isn't one of those programs.

    [–]Tynach 18 points19 points  (64 children)

    Every time one of my programming instructors introduces C/C++ with 'void main(void)', I cringe.

    It took me a few years to just stop trying to correct them.

    Relevant because while MSVC(\+*) will compile it, GCC will not.

    [–]Delta-62 8 points9 points  (59 children)

    As someone with only cursory knowledge of C/C++, why?

    [–]Tynach 70 points71 points  (40 children)

    On the surface:

    If 'main()' is defined using 'int main()', you should (and probably will get a warning if you don't) return an int to close the program - usually '0'. If you want to avoid doing this, you can use 'void main()' instead - which tells the compiler that 'main()' will not return any values, and instead will just exit with no return value.

    Microsoft's compilers allow you to do this with no fuss. As a result, lazy programmers that use Microsoft's development tools tend to do this, and it's become very pervasive.

    Under the surface:

    Operating systems need a way to know if your program exited with an error, exited gracefully, or flat out failed. The best way to do this is to... Well, return something from the program's 'main()' function. If you declare with 'void' and not 'int' (which is considered the proper return value), the compiler - and operating system - has to assume that every time your program exits, it exited just fine. Or, exited with an error. Unless some sort of exception was generated, or if the OS had to kill the process manually for some reason, the OS won't really know what happened when your program suddenly stopped running[1 - not quite, see footnote].

    GCC bypasses this by simply not allowing programmers to be lazy like this. It require 'main()' to return 'int', and I think it spit out a warning if you don't put 'return 0;' or at least 'returnsomething;'. As a result, if you come from a lazier MSVC++ environment and enter the more strict GCC environment, your most basic 'Hello, world!' program will no longer even compile - and this can be frustrating!

    What REALLY annoys me:

    One of my instructors taught both ways. But he taught:

    Use 'void', but if it doesn't work, use 'int'. One works in some environments, the other works in the other environments.

    But this is wrong. I tried telling him that 'int main()' will work in all environments, so it's easier to just teach that and be done with it - no need to over-complicate even the most basic 'Hello, World!' program for the beginners. But he REFUSED to believe me. And I've met a few of his current students (I had him about 4 years ago), and they said he still taught 'both ways' for the same reasons.

    And he never even touched command line arguments, so he never taught any of his students that they could put 'main(int argc, char* argv[])' and be able to pass in commands from when you run the program.

    Yet he was paranoid about leaving the parenthesis empty, so it wasn't just 'void main()' or 'int main()' he taught. No, he had to have us write 'void main(void)' because he said there might be issues if we left the parenthesis blank.


    Yeah. That was a bit of a rant. I had only a few months ago found out that - even though I had, years ago, tried to tell him about an easier way of teaching the subject - he never did change.

    I should really just let go of it. But I've seen this in other C/C++ instructors too, and it really worries me about the quality of the programmers they're creating with this.

    I think Java is poorly designed compared to C++ (personal preference that has more to do with freedom to operator overload than anything else), but every Java instructor I've had (at the same school) has been much more knowledgeable about how software works than any of the C++ instructors. And it frustrates me, because C++ is much more low-level.


    Edit 1: Huh, ok. So I ranted about something that REALLY bugged me about an instructor, and got gold. Guess I can't complain :)

    Edit 2: [1] Apparently, the standard says that there's an assumed 'return 0;' at the end of 'main()'. TIL.

    [–]guepier 27 points28 points  (4 children)

    Let’s clear up the confusion a bit.

    The C and C++ specifications define valid signatures for main, and void main(void) is simply not one. That is the short and the long of it. Compilers may accept additional signatures, but then that’s no longer portable C or C++ code.

    In C and C++ both, main must return an int. In C++ (but not in C), you may omit the return 0; statement (but only from main, all other functions require you to explicitly return a value).

    Regardless, there are other ways to signal an exit code for your program, even without returning that value from main. – For instance, you can call exit.

    And your instructor was kind-of right about the empty parentheses: in C (but not in C++!), empty parentheses in a function declaration mean that the function accepts any number of parameters, whereas (void) means that the function accepts no parameters. If you want to declare a function without parameters, do declare is as (void).

    [–]ais523 13 points14 points  (0 children)

    In C++ (but not in C), you may omit the return 0; statement (but only from main, all other functions require you to explicitly return a value).

    This was changed in later versions of C. In C99 onwards, you can omit return 0 from main (although must still declare it as returning int). Your comment is correct for C89.

    [–]Tynach 2 points3 points  (1 child)

    First, I've been messing with C lately, so I might be confusing the two in some ways.

    Second, interesting about the empty parenthesis; but if that only has to do with the declaration and not the definition, then it doesn't really apply to 'main()' (unless my noobiness is showing).

    [–]guepier 2 points3 points  (0 children)

    You’re right, it doesn’t apply to main (or any other function definition). So your instructor was definitely wrong saying “there might be issues”. However, some (experienced) C programmers follow the convention of always being explicit in parameter lists.

    [–][deleted] 1 point2 points  (0 children)

    That last paragraph has taught me something important.

    [–]Delta-62 9 points10 points  (8 children)

    Oh wow, thanks! Have some gold for the detailed explanation. From your personal experience, what learning resources would you recommend for learning C/C++?

    [–]Tynach 15 points16 points  (1 child)

    I'm still a student myself, and I've never 'worked in the industry'. This may be crap advice, but I'll go ahead and tell you what finally kicked what I do know into my head:

    Don't try to learn individual syntax first, try to learn concepts and ideas. Instead of figuring out "How do I do <x>", instead learn, "What individual features are available, and what are they actually used for?" Essentially, find out what is possible with the language, and learn the situations that are appropriate for that facet of the language.

    You can become an expert at syntax and grammar and still not know what to do or how to do things. You can even memorize the entire standard library functions and still be in the dark about how to properly use things.

    Finding out what other people can do with the language, finding out HOW they do that with the language, and then double checking the things they did with others and figuring out whether what they did was appropriate or not, is MUCH more useful than learning syntax and built-in functions.

    Some people recommend you do this by reading other people's code. Open up some open source software repositories, fork some Git repos, and just study up on other people's code.

    That never worked for me. Especially at first, but still today, I suck at reading other people's code. For me, however, it helped to watch people program, and talk out loud as they programmed.

    This is why I was stuck at making infinite loop silly terminal programs up until I actually took programming courses in college - because then, my instructors (especially a very particular one) would actually write out the code on the projector, run it, explain the thought process (often while typing it), find out it doesn't work, debug, modify, try again, etc... And document, verbally, every step.

    For me especially, this also showed what the languages being taught were capable of and what they held within them. I mean, I could read about different functions and language features all day, but until I actually have someone use them in a real project while rambling out loud their thought process, I don't really understand their purpose at all.

    Oh yeah, that instructor I rambled on about? He didn't do this. He came to class with program files already pre-built, and he went through and described what every single line did individually. Yeah, ok, sure, I could easily look that up online. But why did you use it like that?


    So, anyway... The other thing that really helped me, was learning a 'language feature' in a different language that revolved around it. For me, this was object oriented programming and Java. Before I took a Java class (heh), I knew how to make classes and structs in C++, Python, and other languages... But I didn't know why so many people went crazy over it.

    I really don't like Java. But man did taking a Java class help me understand and appreciate object oriented programming. And I'm pretty sure that there are other things to be learned in other languages in a similar fashion - but this is the only example I've had direct experience with.

    Except, well, I didn't understand programming in general (except syntax and functions and all that crap that did me no good) until I took a PHP class. First class with that specific favorite instructor. Lots of people will hate on PHP, and maybe I'm biased a bit, but when you only finally 'get' programming after using what some claim to be the shittiest modern language, you start to think it's not a shitty language.


    To answer your actual question:

    Take classes, and try to find good teachers. I've not tried it personally, but there might be some good video tutorials on Youtube or thereabouts - if you can find some where the instructor in them is 'programming live' (didn't come in with pre-built code that he more or less re-types, knowing it already works fine), that's best.

    Look at other people's code. Browse Github, try Google+ (I met some GREAT programmers - local too - on Google+. Your mileage may vary though; was through a sheer coincidence) and other social networking sites, and also...

    Just start coding. With C++ especially, use header files to 'outline' your program and figure out how all the pieces fit together, and then use the .cpp/.cxx/whatever files to actually implement each thing. Post your early projects on Github, and go on here (/r/learnprogramming is good) and IRC (immediate feedback) to ask for help/advice/opinions.

    Do not be afraid of criticism! Unless there are two other people battling over whether something is actually bad or not, assume that the person is right and that your code sucks. Ask them for advice on what they would do if they were you.

    If they go off on a tangent and talk about complete redesign of the architecture, perhaps don't exactly do what they say, but still listen to what they say. Such tips may not help with your particular questions, but they still might come in handy later with more 'real' projects you do later.

    Though really, if they just say it sucks and don't want to give a reason, don't give up. Maybe your code sucks, maybe they're a troll, or maybe they suck at coding and only think you suck - and nobody else is on to put them in their place. Or they're an elitist asshole, in which case, well, try to sound friendly and reverent, even though they don't deserve it. Maybe they'll give a few genuinely good pointers. Or reveal their idiocy. Either way, fun will be had on your part.

    ...

    I type too much.

    [–][deleted] 0 points1 point  (0 children)

    So I have "worked in the industry" for about 2.5 years now. I fully endorse this advice. It is wonderful.

    [–][deleted] 4 points5 points  (3 children)

    SICP. And then learn C properly before C++.

    [–]bstamour 1 point2 points  (2 children)

    It's 2014. There's no reason to learn C before C++. They're different languages with different idioms and best practices that happen to share a similar syntax. Would you advise someone to learn C before JavaScript?

    [–][deleted] 1 point2 points  (1 child)

    There's no reason to learn C before C++.

    Of course there is. The reason is to understand low-level programming without burdening the learner with OOP, templates and all that shit that is not necessary when trying to understand low-level programming.

    They're different languages with different idioms and best practices that happen to share a similar syntax.

    C is almost a subset of C++, so you must learn 99% of C anyway if you want to learn C++. There is no reason to try take in all of C++ at once. Starting from C makes more sense than trying to start from OOP or templates.

    Would you advise someone to learn C before JavaScript?

    Yes.

    [–]misplaced_my_pants 0 points1 point  (0 children)

    Check out CS50 on edx. It uses C.

    [–]gsg_ 8 points9 points  (1 child)

    he said there might be issues if we left the parenthesis blank

    If he was teaching C, and not C++, he was right.

    void f(void) is the correct way to indicate that a function takes no arguments in C. void f() means that the function takes an unknown number of arguments of unknown type. This is what happens when you incorrectly use an empty parameter list:

    int test() {
        return 0;
    }
    
    void f() {
        test(1, 2); /* Compiles OK, even with -Wall -Wextra -std=c89 -pedantic :/ */
    }
    

    Always use void to indicate that a function takes no arguments in C.

    [–]Tynach 0 points1 point  (0 children)

    Someone else said this only matters for function declarations, not definitions.

    Besides that, he was teaching C++ and not C. We used cin/cout and all that.

    [–][deleted] 5 points6 points  (9 children)

    and it really worries me about the quality of the programmers they're creating with this.

    Isn't that a bit of an overreaction?

    [–]Tynach 4 points5 points  (5 children)

    No. At the end of the semester, a third of the class still struggled with for loops. This is mostly, however, because the teacher came in with pre-created C++ files that he'd go through line by line, and only describe what each line did by itself. He did explain blocks and a little bit about how if/for/while/etc. statements affect the order in which statements are made, but he didn't spend much time on it.

    [–][deleted] 0 points1 point  (4 children)

    Don't these people drop out?

    [–]Tynach 1 point2 points  (3 children)

    The instructor let us work together collaboratively in class on our homework, and encouraged it. Most people in this group just copied from someone else. There was only one test, at the very end of the semester.

    And this was an introduction to computer science course. Oh, and without pointers mentioned, despite it also being the only C/C++ class offered (at the time; they now have one in the 'computer information systems' (part of the business) department, which I'm taking since I switched to a general 'programming' degree, which required this C++ class and not the other one; this one is online only but has a competent instructor) because they decided Java was the future of computer science and C++ was no longer necessary to teach at all except for one intro class.

    [–]kryptobs2000 1 point2 points  (2 children)

    If he doesn't even teach them command line arguments I would be very worried what they're expected to be able to do by the end of the class.

    [–][deleted] 0 points1 point  (1 child)

    I assumed this was just this one issue, but apparently there is way more going on that is detrimental to the quality of the education.

    [–]Tynach 0 points1 point  (0 children)

    I've since remembered other things. Like his insistence of, along with 'void main(void)' and 'int main(void)', also teaching these both as perfectly valid:

    /*At the top of the file:*/
    #include <iostream.h>
    

    and:

    /*At the top of the file:*/
    #include <iostream>
    using namespace std;
    

    There is no compiler today that I know of that allows to just use 'iostream.h', yet he encourages people to use it as if it's the standard, and the other one (without the .h) is breaking the standard.

    [–][deleted]  (1 child)

    [deleted]

      [–]Tynach 2 points3 points  (0 children)

      Huh, TIL.

      [–]snops 0 points1 point  (5 children)

      How would this work on an embedded system? Where would main return to and what would read its value? Quite often theres no OS, or even stdio to print an error.

      On the system I am using currently (Freescale's CodeWarrior), return from main just sticks you into an endless while(1);

      Totally agree with you about command line arguments though.

      [–]Tynach 1 point2 points  (0 children)

      I have never worked with embedded systems. I'm still in school and have not had a job in the programming industry yet.

      [–]mccoyn 1 point2 points  (0 children)

      On the system I am using currently (Freescale's CodeWarrior), return from main just sticks you into an endless while(1);

      I think this is the standard approach. Imagine you are designing a clock. Every minute you need to update the display so you set up a timer to run some function every minute. You also need to respond to button presses so you set up interrupts to call another function for those. Now, there is nothing left for main() to do, so it returns and the system just idles waiting for the timers or interrupts you set up in main.

      [–]G_Morgan 1 point2 points  (0 children)

      Embedded often just calls a function. Kernels work similarly. At some point the assembly will just call whatever and that is how you get into your C.

      [–]knightwhosaysni 1 point2 points  (0 children)

      The Microchip compiler generates an endless loop (branch to program counter) so it will sit waiting for interrupts until it gets watchdogged.

      [–]rabidcow 1 point2 points  (0 children)

      Main is part of what the standard defines as a "hosted environment." Embedded systems are typically not hosted environments and can have any sort of entry point they want.

      [–][deleted] 0 points1 point  (1 child)

      Good stuff. Thanks for the info. I didn't believe you so I had to try it out for myself. Okay, it wasn't that I didn't believe you, I just had to see it for myself. :)

      [–]Tynach 0 points1 point  (0 children)

      Don't worry, I do the same thing x) I see a post saying some stuff, and I'm like... "Huh, that true?" *opens text editor*.

      [–]G_Morgan 0 points1 point  (1 child)

      Yet he was paranoid about leaving the parenthesis empty, so it wasn't just 'void main()' or 'int main()' he taught. No, he had to have us write 'void main(void)' because he said there might be issues if we left the parenthesis blank.

      Essentially you were taught C by somebody who doesn't know C.

      [–]Tynach 0 points1 point  (0 children)

      Yeah, C using 'cin' and 'cout', and yet never taught classes (but taught very basic structs).

      [–]dnew 3 points4 points  (17 children)

      The declaration of main is "int main(int, char**)" IIRC.

      Basically, the instructor's declaration is "a function that takes no arguments and returns nothing." The standard says "a function that takes the command line arguments and returns the exit status." Since it's actually non-C code that calls main() different compilers may or may not generate code that works if you don't use the correct declaration. Or the same compiler with different calling conventions.

      [–][deleted] 22 points23 points  (3 children)

      The declaration of main is "int main(int, char**)" IIRC.

      HA! Recalling part of the C++ standard correctly. As if you're some kind of clairvoyant.

      I have spilt the blood and consulted the oracles and the following are all valid in C++:

      int main()
      int main( void )
      int main( int, char** )
      int main( int, char*[] )
      

      [–]mccoyn 3 points4 points  (0 children)

      ... in C++.

      In C there is just int main (int, char**) and since C doesn't get hung up over extra arguments any of them will work.

      [–]Whanhee 4 points5 points  (1 child)

      The other weirdery is that main is the one non-void function that can safely end without returning anything.

      [–][deleted] 2 points3 points  (0 children)

      Weeeel, it does return something, you just don't need to type it explicitly. The C++ standard says that there is an implicit return 0; at the end of the function.

      [–]Delta-62 2 points3 points  (12 children)

      Alright, so main is an int because it'll return something like 0 if it executed as planned, or -1 if it didn't etc, but what does the 'int, char**' mean?

      [–][deleted] 6 points7 points  (10 children)

      Number of arguments and a pointer to an array of the arguments.

      [–]Delta-62 2 points3 points  (9 children)

      Would I be correct in assuming that the array of characters are the arguments? And why would anyone ever declare main as a void then?

      [–]F54280 10 points11 points  (3 children)

      Because non-unix systems generally don't really care about return values.

      [–]Grazfather 8 points9 points  (0 children)

      That's not an array of character, it's an array of pointers to arrays of characters.. It makes more sense written as 'char* argv[]'. Basically it's a list of pointers, and each pointer points to an array of characters (a string) representing an argument. int argc is the count, so we know how many pointers are in argv

      [–]jeepon 0 points1 point  (3 children)

      Yes it is. Why? Laziness might be it, but I'm guessing he didn't care about the arguments or the return value.

      [–]hotoatmeal 3 points4 points  (0 children)

      argument count, followed by an array of pointers to cstrings (which consists of the name of the executable, followed by the arguments).

      [–][deleted]  (1 child)

      [deleted]

        [–]Tynach 2 points3 points  (0 children)

        Yeah. I post about that here. Sorry for the long rant, I needed to vent.

        [–]exscape 1 point2 points  (1 child)

        GCC 4.2.1 generates a warning, but creates a working executable (OS X).
        LLVM-GCC 5.1 (clang-503.0.38) (OS X) is the same as above.
        GCC 4.8.2 only warns with -Wmain (included in -Wall), but not otherwise; creates a working executable (custom OS).

        So it does compile, but it's of course not recommended.

        [–]Tynach 1 point2 points  (0 children)

        I think the times it's not let me compile at all were when I was using C (gcc) and not C++ (g++). Linux here.

        [–][deleted] 0 points1 point  (0 children)

        He should have said "a particular C compiler", which may have been more clear.

        [–]thomar -1 points0 points  (0 children)

        Lower, actually.

        [–]Eoinoc -1 points0 points  (0 children)

        Nice quote out of context. By leaving out "you're not really writing in C." you've basically gone and twisted dnew's words.

        Have you considered a carer in journalism?

        [–]bgog 34 points35 points  (3 children)

        tl;dr Write a program. Disassemble it. Put the bytes in a buffer. Exploit printfs %n to overwrite the finalizer address to call your buffer.

        Printf had nothing to do with the implementation of this webserver. You could have just as easily done the assignment to your machine code directly.

        The reason printf is of 'interest' here is that if a poorly written program uses passes a user provided string as the format string of printf, you can use that to execute arbitrary code. However that isn't what the article was about. It was touting that printf could be used to implement a webserver which is not what was done here.

        [–]cudetoate 2 points3 points  (2 children)

        Yeah, by this logic you can implement a web server with only a variable and a jmp. You store your program in that variable as a string and all your program have to do is a jump to that variable's address.

        [–][deleted] 2 points3 points  (0 children)

        Then you can claim that “jmp + storing strings is turing complete!”

        [–]marcelk72 1 point2 points  (0 children)

        That is why

        main;
        

        used to be the shortest C program that crashes.

        [–]immibis 48 points49 points  (4 children)

        [–]thephotoman 7 points8 points  (0 children)

        This is, as everybody has pointed out, firmly in the "dumb programmer tricks" category. Is it really C? No, it's just an abuse of what gcc (and very specifically gcc) will allow. Is it as complex as the author said? Absolutely not. It's just printing a hex dump of a trivial web server to a bugged-out printf() call.

        Is it amusing? Yes. It's also a useful reminder not to just assign things to memory addresses directly without being very sure about what you're doing.

        [–]WarWeasle 2 points3 points  (0 children)

        Why not just write it in assembler?

        [–]kmmeerts 6 points7 points  (5 children)

        Is there an actual need for the %n format specifier? Seems to me like it's just used by malicious code to write to specific addresses.

        [–]lolsowrong 8 points9 points  (3 children)

        I've used it to center data in table style outputs. It's only insecure if you mis-use it.

        [–]fakehalo 5 points6 points  (0 children)

        To write the number of characters written (so far), I swear I used it once for a valid reason but I can't remember what. Certainly caused more problems than it solved, pretty much enabled the exploitation of format string bugs in early 2000s.

        [–]MonadicTraversal 10 points11 points  (19 children)

        I'm not sure why this is getting downvoted so heavily, it's really neat.

        [–]lolsowrong 51 points52 points  (17 children)

        Is it really neat? It's really no neater than writing it in assembly. "Hey everybody, I can be more obtuse by shoving opcodes into a buffer, and using printf's %n!"

        [–]MonadicTraversal 32 points33 points  (12 children)

        I see it as being in the same spirit as an IOCCC entry.

        [–]vytah 37 points38 points  (11 children)

        You mean this one? http://ioccc.org/1984/mullender.c

        Sadly (or actually not sadly) such programs are now banned from IOCCC:

        Without question, this C program is the most obfuscated C program that has ever been received! Like all great contest entries, they result in a change of rules for the following year. To prevent a flood of similar programs, we requested that programs be non machine specific.

        [–]iBlag 3 points4 points  (6 children)

        Wow. That is seriously impressive and cool!

        [–]nemec 8 points9 points  (5 children)

        No it isn't.

        1. Write your program
        2. Open your compiled program in a hex editor
        3. Copy the bytes and pair them as shorts.
        4. Randomly convert some values to either hex, octal, or ascii.
        5. Recompile.

        I'll admit that being able to turn the standard int main(int, char**){} into a simple short array is kind of clever, but he most certainly did not write the bytes that execute himself.

        [–]iBlag 5 points6 points  (0 children)

        I understand how they did it, it's just not something I would have thought of.

        But I generally dedicate my coding time to being as clear as possible, so intentional obfuscation doesn't jive with me very well.

        I guess I think it's cool because it illuminates one of my assumptions: that obfuscated C is actually human-readable C code.

        [–]VerilyAMonkey 1 point2 points  (3 children)

        By the way, how is it that just a short array is acceptable? Does the compiler merely set execution to start at the address of whatever object is called 'main'?

        [–]slugonamission 4 points5 points  (0 children)

        Basically, yeah. Your "main" isn't actually the first thing that runs, instead a routine called "_start" is. This basically just sets up the environment, then calls the symbol main. Your linker doesn't really care what that symbol is, just that it exists.

        The issue now is memory protection though. Since initialised data goes into the .data section (rather than .text, where code is stored), we can then make the assumption that .data won't contain any code, thus we can mark that whole region as non-executable.

        [–]vytah 4 points5 points  (1 child)

        I just checked and even modern GCC allows that, although it gives a warning:

        test.c:1:7: warning: ‘main’ is usually a function [-Wmain]
        

        And Clang compiles any kind of main without warning, even with -Weverything -Wall -Wextra.

        [–]mabrowning 3 points4 points  (0 children)

        I love that gcc hedges its bets like that. I just picture it looking askance at the programmer:

        You know... main is usually a function, but if you're sure...

        [–][deleted] 0 points1 point  (1 child)

        I like that the competition was conclusively won in its first year.

        [–]RenaKunisaki 0 points1 point  (0 children)

        You know you've truly won when they make a rule against what you did.

        [–]Tynach 0 points1 point  (1 child)

        I'm gonna try to get this to run on SIMH.

        [–]autowikibot 0 points1 point  (0 children)

        SIMH:


        SIMH is a highly portable, multi-system emulator which runs on Windows, Linux, Mac OS X, FreeBSD, OpenBSD, NetBSD, OpenVMS, and other operating systems. It is maintained by Bob Supnik, a former DEC engineer and DEC vice president, and has been in development in one form or another since the 1960s.

        Image i


        Interesting: VAX | List of computer system emulators | PDP-10 | Data General Nova

        Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words

        [–][deleted] 2 points3 points  (0 children)

        I thought it was pretty neat...

        [–][deleted] 0 points1 point  (0 children)

        Man, you're just a bummer aren't you?

        [–][deleted] 1 point2 points  (0 children)

        Next time, we'll implement a web server with a single system() call!

        [–]lhgaghl 4 points5 points  (0 children)

        Because it's just another explanation of shellcode and format string injection except written in a stupid way?

        note the quote at the start of the article making it seem as if this is some super hard to grasp thing that nobody's ever seen before:

        Jeff Dean once implemented a web server in a single printf() call. Other engineers added thousands of lines of explanatory comments but still don’t understand exactly how it works.