This was linked in the comments (by the author):<p><a href="https://www.facebook.com/sedatk/posts/10151240841812644" rel="nofollow">https://www.facebook.com/sedatk/posts/10151240841812644</a><p><i>Sedat Kapanoglu · 2,372 followers<p>3 hours ago near Maslak, Istanbul<p>Today I was at the Istanbul courthouse third time this year. I attended a trial defending myself to a judge. Then I bore my testimony to a prosecutor about a different case. Both cases were about the free speech platform I own in Turkey. Meanwhile in the world, one of my older posts in Stackoverflow became Hackernews #1 & reddit/programming #1. I wish it was Turkey which made me feel better about myself, not the rest of the world.</i>
The poor compilers do the best with what they have. And by "what they have", I mean the things they can't make assumptions about. Which turns out to be a crapload. Until that happens, very highly-tuned assembly will continue to outperform the best compilers.<p>Of course, a more typical scenario is hand-tuning a few loops where 99% of the clock cycles occur and letting the compiler take care of the rest.<p>(Also, I was attempting to send a Morse code message by flashing the vote counter between up and down, but I don't think anyone got it :( )
Cute. Although I think my compiler has different things to say.<p>Hello, I'm a C compiler that still can't handle C99. I hope you're wearing waterproof clothing because I'm gonna throw up on you. Also, I've been drinking heavily so your C++ code is going to take a while to compile and when it's done, it's gonna smell funny.
Hello. I'm a programmer.<p>I noticed you couldn't optimize my code to use SIMD so I went ahead and used inline assembly. It will probably take another 30 years before you can actually think like a human and perform optimizations like this.
This answer purports a myth that compilers are magical black boxes, the sum of millions of hours of intense academic research that "you will never understand".<p>Replace "compiler" with "computer". Doesn't that make you angry? Answers like these do nothing but prevent people from learning about them.<p>If you are interested in compilers, here's Edinburgh University's notes from the course "Compiling Techniques", probably a good place to start. Don't let internet tough-guys stop you from learning.<p><a href="http://www.inf.ed.ac.uk/teaching/courses/ct/" rel="nofollow">http://www.inf.ed.ac.uk/teaching/courses/ct/</a>
And on the Fourth Day, God proclaimed "Thou shalt have the ability to use inline assembly in thy C/C++ code for performance-critical tasks".<p>I can think of absolutely zero reason to write an entire program in x86 assembly, let alone any other kind of assembly (GCC spits out some pretty optimized code for my little Atmel MCU)... It's a lot nicer to write everything in a high-level, and then write any performance specifics in inline assembly.<p>The really cool thing to see is how other newer languages have adopted this scheme (e.g. PyASM for Python, or the ability to edit the instructions for interpreted languages that run in their own VM). And as always, great power comes with great responsibility ;)
Are they pushing those realtime vote counts with websockets? Pretty slick. Beats polling by far.<p>Looks like IE is holding it back as usual:<p><a href="https://developer.mozilla.org/en-US/docs/WebSockets#Browser_compatibility" rel="nofollow">https://developer.mozilla.org/en-US/docs/WebSockets#Browser_...</a>
Isn't Steve Gibson ( <a href="http://www.grc.com/stevegibson.htm" rel="nofollow">http://www.grc.com/stevegibson.htm</a> ) still coding large, complex programs in pure assembly?<p>His work on spinrite is legendary, for those born before IDE hard drives were invented.
Fascinating, while I was reading that, it got 5 upvotes! Mindblowing.<p>This is a really awesome description too. The only thing I know about compilers is that I implemented one for class (without fancy optimisations) and I am surprised any software works, ever. Compiler are just ... mindbogglingly complex things. Almost as much voodoo dark magic as engineering.
Anytime I read about the topic of assembly language, I can't help but think of Michael Abrash. For example, check out Chapter 22 [1] from his <i>Graphics Programming Black Book</i> entitled <i>Zenning and the Flexible Mind</i> for a pleasant stroll down Optimization Lane.<p>You might also enjoy his book entitled <i>The Zen of Assembly Language</i> which features the Zen Timer (a timing tool for performance measuring).<p>[1] <a href="http://downloads.gamedev.net/pdf/gpbb/gpbb22.pdf" rel="nofollow">http://downloads.gamedev.net/pdf/gpbb/gpbb22.pdf</a>
The best comment:
"Thank you compiler, but perhaps if you weren't commenting on StackOverflow, you could get me a drink and play some nice music while you're working?"
Hey, my name is ICC, and I'm one of the most respected compilers in the industry. I also sabotage your code so that it works poorly on AMD CPUs, while making sure that Intel CPUs run my code at full speed. After all, Intel likes to establish market dominance.<p><a href="http://www.agner.org/optimize/blog/read.php?i=49#49" rel="nofollow">http://www.agner.org/optimize/blog/read.php?i=49#49</a><p>Blind trust in the compiler is bad people. Good luck discussing this issue without any Assembly Programers who can fully understand what is going on here.
Hello, I am a programmer.<p>I have little idea what modern day compilers are doing, or what the CPU, or the operating system is doing for that matter. Often, way too often, compilers fail, hardware fails, operating systems fail, lots of things fail. I am not going to read the millions of lines of code written by other programmers (in f-ing emacs no less) in the any number of differing complex beasts, the compilers. It seems crazy-making to me, that other programmers would create compilers that would use millions of possibilities of optimizing a single line of mine using hundreds of different optimization techniques based on a vast amount of academic research that I won't be spending years getting at. I do feel embarrassed, yes very icky, that I have little to no idea what a three-line loop will be compiled as, but bloat would be my guess. There is risk in going to great lengths of optimization or doing the dirtiest tricks. And if I don't want the compiler to do this, I have no idea how to stop this behavior, nor do I want to invest in the specific knowledge of the nuances any particular compiler. The compiler does not allow me easy access because the compiler itself is an overly complex piece of software written by other programmers. I could care less about how a compiler would make my code would look in assembly, on different processor architectures and different operating systems and in different assembly conventions. Transformation comes with how we as programmers write code, not in compiler-fu.<p>P.S. Oh, and by the way if I really wasn't using half of the code I wrote, I would throw the source code away.
Hello. I'm an assembly programmer. I used a compiler to generate the majority of code, and can hand-craft any assembly that comes out of it. I understand how compilers auto-generate SIMD instructions can be more easily compiler-generated if I make a "struct of arrays" instead of "an array of structs".<p>TLDR: Real performance programmers need to understand the assembly a compiler generates if they hope to tune the compiler to generate optimal assembly. Also, GCC -O3 is prone to removing too much code and reordering it, causing memory barrier issues and the like. All multi-threaded programmers need to understand how the compiler generates assembly (ie: by reordering your code), and how it can generate new bugs if you don't use the right compiler flags.
I never noticed that the Stackoverflow js pulls updates for vote tallies in real-time. Browsing this answer while HN is sending lots of traffic there is almost like watching a car odometer.
It is funny how people want to believe in tools. In fact, the optimizations compiler does are incomparable with those programmer could do by choosing an appropriate data-structure with corresponding algorithms and by being aware of strengths and weakness of a particular CPU architecture.<p>JVM, which is nothing but a stack-based byte-code interpreter is the most famous case.) People seems to believe it can do wonders, especially in memory management and data throughput.<p>It is so strange to see how people are trying to create a whole world inside a JVM. What it is called when people are building models of ships inside a bottle?)<p>btw, now, it seems, they are trying to build a whole world inside a V8 bottle.)