(When) Should I learn compilers?

Peter picture Peter · Apr 9, 2009 · Viewed 12.5k times · Source

According to this http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html article, I defnitely should.

Quote Gentle, yet insistent executive summary: If you don't know how compilers work, then you don't know how computers work. If you're not 100% sure whether you know how compilers work, then you don't know how they work.

I thought that it was a very interesting article, and the field of application is very useful (do yourself a favour and read it) But then again, I have seen successful senior sw engineers that didn’t know compilers very well, or internal machine architecture for that matter, but did know a thing or two of each item in the following list :

  • A programming paradigm (OO, functional,…)
  • A programming language API (C#, Java..) and at least 2 very different some say! (Java / Haskell)
  • A programming framework (Java, .NET)
  • An IDE to make you more productive (Eclipse, VisualStudio, Emacs,….)
  • Programming best practices (see fxcop rules for example)
  • Programming Principles (DRY, High Cohesion, Low Coupling, ….)
  • Programming methodologies (TDD, MDE)
  • Design patterns (Structural, Behavioural,….)
  • Architectural Basics (Tiers, Layers, Process Models (Waterfall, Agile,…)
  • A Testing Tool (Unit Testing, Model Testing, …)
  • A GUI technique (WPF, Swing)
  • A documenting tool (Javadoc, Sandcastle..)
  • A modelling languague (and tool maybe) (UML, VisualParadigm, Rational)
  • (undoubtedly forgetting very important stuff here)

Not all of these tools are necessary to be a good programmer (like a GUI when you just don’t need it) but most of them are. Where do compilers come in, and are they really that important, since, as I mentioned, lots of programmers seems to be doing fine without knowing them and especially, becoming a good programmer is seen the multitude of knowledge domains almost a lifetime achievement :-) , so even if compilers are extremely important, isn't there always stuff still more important?

Or should i order 'The Unleashed Compilers Unlimited Bible (in 24H..))) today?

For those who have read the article, and want to start studying right away :

Learning Resources on Parsers, Interpreters, and Compilers

Answer

Tom picture Tom · Apr 9, 2009

If you just want to be a run-of-the-mill coder, and write stuff... you don't need to take compilers.

If you want to learn computer science and appreciate and really become a computer scientist, you MUST take compilers.

Compilers is a microcosm of computer science! It contains every single problem, including (but not limited to) AI (greedy algorithms & heuristic search), algorithms, theory (formal languages, automata), systems, architecture, etc.

You get to see a lot of computer science come together in an amazing way. Not only will you understand more about why programming languages work the way that they do, but you will become a better coder for having that understanding. You will learn to understand the low level, which helps at the high level.

As programmers, we very often like to talk about things being a "black box"... but things are a lot smoother when you understand a little bit about what's in the box. Even if you don't build a whole compiler, you will surely learn a lot. You will get to see the formalisms behind parsing (and realize it's not just a bunch of special cases hacked together), and a bunch of NP complete problems. You will see why the theory of computer science is so important to understand for practical things. (After all, compilers are extremely practical... and we wouldn't have the compilers we have today without formalisms).

I really hope you consider learning about them... it will help you get to the next level as a computer scientist :-).