Ben Cantrick (mackys) wrote,
Ben Cantrick
mackys

  • Mood:

If you don't know how compilers work, then you don't truly know how computers work.


If you don't know how compilers work, then you don't truly know how computers work. If you're not 100% sure whether you know how compilers work, then you don't know how they work.

In fact, Compiler Construction is, in my own humble and probably embarrassingly wrong opinion, the second most important CS class you can take in an undergraduate computer science program.


The first reason Compiler Construction is such an important CS course is that it brings together, in a very concrete way, almost everything you learned before you took the course.

You can't fully understand how compilers work without knowing machine architecture, because compilers emit machine code. It's more than just instructions; compilers need to understand how the underlying machine actually operates in order to translate your source code efficiently.

Incidentally, "machines" are just about anything that can do computations. Perl is a machine. Your OS is a machine. Emacs is a machine. If you could prove your washing machine is Turing complete, then you could write a compiler that executes C code on it.

But you knew that already.

You can't understand how modern compilers work without knowing how Operating Systems work, because no self-respecting machine these days runs without an operating system. The OS interface forms part of the target machine. Sure, you can find people working on five- to ten-year mainframe projects that ultimately run no faster than a PC from Costco, and they may dispense with the operating system due to time constraints, plus the fact that they have a worldwide market of one customer. But for most of us, the OS is part of the machine.

You won't understand how compilers work unless you've taken a theory of computation course. The theory of computation reads like part one of chapter 1 of a compilers book. You need all of it.


http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html


This is a long rant, but I enjoyed it. Compiler construction was the one CS class that I never got to take in college, and to this day I'm still annoyed about that. I've tried to teach myself to an equivalent level. I bought the Dragon book, I know what a BNF grammar and LALR parser are, I learned lex and yacc, even wrote my own small Forth interpreter with them. And I'm still not sure if I'm smart enough to create my own languages and compilers.

Incidentally - Do not use the Dragon book as your first book on compiler construction! Hardcore C programmers with a lot of spare time to write code will be much better served by Ronald Mak's "Writing Compilers and Interpreters". Everyone else who just wants a good introductory text... well I'm still looking. Torben Mogensen's "Basics Of Compiler Design" is worth a shot.
Tags: digg
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments