Why take a compiler course? (2010)
Despite the fact that my algorithms course was ostensibly about learning how to come up with efficient solutions to various problems, the two courses I took that have helped me the most with writing performant code in my career were my compilers course and my architecture course. The compilers course gave me a much stronger understanding of what actually happens when running a line of code I wrote and helped me understand better what types of optimizations could potentially be performed based on the way I write an algorithm, and the architecture course taught me about how a modern CPU actually works with regards to caching, out-of-order processing, branch prediction, etc.<p>On the other hand, the types of things we discussed in my algorithms course felt very hit-or-miss with regards to whether they actually felt useful or not. I&#x27;m not just talking about high-level abstractions that can miss important details in the real world like &quot;memory can be accessed in constant time&quot; either, but solving problems that were so contrived to the point of being almost implausible. The example I always remember is that in one of our problems sets, we were asked to write an algorithm that sorted an array of size N with each element within K indices of the correct sorted position in O(n*log(k)) time. I can&#x27;t think of any situation where I&#x27;d have data so large with a small enough strict upper bound on K that such an algorithm would be necessary, but even if I did find myself in that situation, that&#x27;s the exact type of input that the naive quicksort implementation would perform more efficiently on!<p>Maybe someday we&#x27;ll have powerful enough tools that we can generate code that&#x27;s performant without needing to do it ourselves, but at least for now, writing code that a computer executes efficiently is much easier when you actually understand what&#x27;s being run on the computer and how it runs it, and a compilers course is a great way to start learning about the first half of that.