When I was in my very first undergraduate programming class, they hammered into me on very important truth:
The compiler is never wrong
The compiler has no bugs in it, the libraries have no bugs. If you’re not getting the output you expect, then the bug is in your code. Nearly every week, someone would be there furiously muttering to the tutor that he just needs to LOOK at this example because the code is so OBVIOUSLY correct that it MUST be a compiler error of some kind. And every time it happened, the tutors would simply smile complacently back and remind the student that “The compiler is never wrong”. Eventually, with enough repetition, we understood this fact down deep into our bones and I think it’s made us better programmers as a result of it.
On the face of it, this is absurd. Compilers are programs just like anything else and they contain bugs like every other program. If we were talking about established, battle scarred compilers like gcc, you might be able to make a credible argument but we were working with the Glasgow Haskell Compiler which most certainly did have bugs in it.
The statement “The compiler is never wrong” has such power because it’s so patently easy to prove false. And as I grow older and think I understand more and more about the world, some of the most powerful beliefs that you can hold are the obviously wrong truths. You can never tell an obviously wrong truth to someone who is not ready to hear it because it’s so obviously wrong. You need to take a leap of faith and accept that something can be obviously wrong and still true for such things to make sense.
If this sounds supiciously like what you’ve heard religious people say, it’s because maybe this is what religion is…