Today I’m channeling my inner grumpy old man. And these guys are helping. (I am not old enough to pull off such a face by myself, although life is rapidly helping me get there. ;-)
The reason I’m feeling grumpy is that I’ve had another in a long, long line of conversations about how to write faster code.
It’s not that optimization experts are dumb. Far from it. They are invariably smart, and in general, they are better informed than I am about how pipeline burst cache and GPUs and RAM prefetch algorithms work. I generally learn a lot when I talk to guys like this.
I applaud their passion, even if I think they sometimes get carried away.
No. What’s making me grumpy is that after decades of hard work, we still have compilers that encourage a culture of black magic and superstition around this topic. I thought I signed up for computer science, not voodoo.
To show you what I mean, let’s talk about the humble
inline keyword in C and C++. The amount of FUD and nonsense around it is really unfortunate. How many of the following have you heard?
Here’s a simple little test that teaches an important lesson. Take a moment to work through all 3 questions. I promise it won’t take long. :-)
Question 1. A flood is coming. George can only swim for a little while. What should George do?
Question 2. A flood is coming. George can only swim for a little while. What should George do?
Question 3. A flood is coming. George can only swim for a little while. What should George do?
Ready to grade your answers?
The Yellow Belt Answer
Most people say “go right, toward higher ground” if picture 1 is the only input to their analysis. The logic is pretty indisputable. But…
I’m glad newly minted software engineers are exposed to data structures, compilers, concurrency, graph theory, assembly language, and the other goodies that constitute a computer science curriculum. All that stuff is important.
But it’s not enough.
Not all classroom material for CS folks should be technical. Photo credit: uniinnsbruck (Flickr).
Since I’m half way to curmudgeon-hood, I frequently find myself lamenting educational blindspots in the young. I’ve even toyed with the idea of teaching at the nearest university, some day when I Have More Time™. If academia would take me, my lesson plans might cover some of the following topics: