Why Is Multi-Threaded Programming So Hard?

As we dive headlong towards a many-core CPU world, the challenge of writing software that takes advantage of that world becomes critical. Otherwise, many programs degrade in performance as single fast cores are replaced with multiple slower ones.

I suspect we are best at single-threaded, sequential programming because it parallels our own lives and bodies. It's hard to do more than one thing that takes conscious thought at a time. While our bodies consist of complex interacting subsystems, we are largely unaware of their inner workings, timings, and dependencies.

The mainstream history of computing is about single-threaded sequential processing - probably because it's easier for people to think that way. The famous VonNeuman machine is such an example.

I have been in many design and debug sessions with other programmers and we have a tendency to personify and identify with our software - "and then I send you the user input and you send it to him to store." It's hard to conceptualize a multi-threaded process in such an analogy.

I wonder if there are cultural effects. Some cultures are famously known for de-emphasizing the individual. Could that upbringing make it easier to design multi-actor (which is different from multi-threaded) software?

Perhaps this is another manifestation of Conway's Law, which states that the structure of software reflects the structure of the organization that produced it. In this case, the "organization" is a single programmer. Because we don't have an internal mental model for consciously doing more than one thing at once, we don't write our code that way.

changed January 17, 2009