Hacker News new | ask | show | jobs
by oliland 4862 days ago
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".

Replace "compiler" with "computer". Doesn't that make you angry? Answers like these do nothing but prevent people from learning about them.

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.

http://www.inf.ed.ac.uk/teaching/courses/ct/

5 comments

>computers are magical black boxes, the sum of millions of hours of intense academic research

Isn't that awesome? I can use the thing without ever understanding what it does :) I'm so glad my car works without me ever having to know anything about how it works. I know it requires some form of money (gas) to work. That's it. Money in -> Transport out. Perfect.

The linked post never proclaimed no one "will ever understand" compilers. That's just what you're reading into it. You try to get upset at it, so you do. It merely proclaims that compilers are incredibly complex, which is the nice thing about them. If compilers were stupid they'd be a lot less useful.

He's just saying the answer makes compilers sound intimidating.
Compilers are intimidating.

I mean, the basics of parsing and lexing are easy enough to understand & do and forming an AST is straightforward but all the "clever stuff" adfer that, all the hundreds and thousands of optimisation tests that are done - they are mind boggling.

Each one by itself is pretty straightfoward but start adding them up and layering them on top of each other and it gets crazy pretty quick.

That doesn't make me angry. I fully accept there are aspects of the stack that allow me to type this message that I will never understand.

Can you e.g. explain how a transistor works, from basic quantum mechanical principles? If not, then there's something in the stack you may never understand, because you're simply not interested in spending the time necessary to understand that at the level a physicist does.

I think you might have misinterpreted the context of "optimizing a single line of yours using hundreds of different optimization techniques based on a vast amount of academic research that you would spend years getting at" was lost.

He isn't saying compilers are based on a "millions of hours of intense academic research that you won't understand". He's saying the specific optimizations implemented by these compilers are based on "millions of hours of intense academic research that you won't understand".

While the general theory behind compilers isn't particularly complex (and is totally worth learning! Your message about people learning about compilers is spot on), production compilers do employ a significant number of complex optimizations. You won't be able to match these unless you spend a very significant amount of effort learning about these specific optimization techniques.

While learning the theories behind compilers is quite useful, I'd argue that learning N tricks to more efficiently translate C into ASM isn't practical unless you want to turn your compiler into a production one.

Sure you can understand the basics of a compiler from a college course on them. But what sets apart industrial level compilers is all the accumulated knowledge built into them. Students are expected to understand the whole compiler they build for class. But how many people understand every single optimization that GCC can do?

My point is, there's understanding how compilers work, and then there's understanding all of GCC. I wouldn't like it if someone made the former sound too intimidating for me, but I don't mind feeling intimidated by the latter.

Keep in mind that it's an answer to the question "Why don't we program in assembly?"

Computer Science majors should be familiar with how compilers work and the theory behind them. But the answer to the question is that for 99% of cases, using a higher-level language and leaving the optimization to a compiler written by subject matter experts makes sense. (ie. Don't re-invent the wheel.)