Threads considered harmful
Many have or will shortly embark on the adventure of writing parallel programs. It is, therefore, useful to reflect on what mistakes we might avoid.
My favorite quote is one often attributed to Mark Twain as "History may not repeat itself, but it does rhyme a lot."
Reflecting on a seminal paper (letter) some 40 years ago, "Goto Statement Considered Harmful " by Edsger Dijkstra published in Communicatons of the ACM in March 1968, I see a rhyme in the making.
Dijkstra's letter was short, and included the statement "The go to statement as it stands is just too primitive; it is too much an invitation to make a mess of one's program."
His paper is widely considered to have pushed the industry to a higher level of abstraction - specifically to structured programming (as in block-structured languages).
I still remember vividly those who argued years after his paper was published that eliminating the 'goto' statement would infringe on creativity. In fact, a series of published arguments in favor of the Goto Statement created a response from Dijkstra 20 years after his initial letter entitled "On a somewhat disappointing correspondence" in which he said "The whole correspondence was carried out at a level that vividly reminded me of the intellectual climate of twenty years ago, as if stagnation were the major characteristic of the computing profession, and that was a disappointment."
By now, we certainly know that some programs fail to pass the test of time. Such programs will be re-written because they are too bound to the hardware, embody hard to maintain programming styles, or otherwise express things in a complex manner which can be stated more easily using newer methods.
Today, we have many parallel programs. They are often written using native threads (pthreads , Windows threads, Java threads or Boost threads ).
In the end, they make a mess of a program. Threads are necessary plumbing, but in applications they simply result in programs which will not pass the test of time. Parallel programming, in order to stand the test of time, needs higher level programming methods.
The practical side of me suggests use of any threaded library, OpenMP or TBB. A less practical side encourages looking at new programming languages like Erlang or Haskell. Either way, the more abstact expression of a program will hold up better over time than the lower level of programming associated with native threads.
Are we going to rhyme, and write lots of parallel code with the modern equivalent of the "Goto Statement"?

