wtorek, 23 września 2014

The (unpleasant) truth about concurrency

As Robert C. Martin writes in his wonderful book "Clean code", concurrency is hard. Concurrency is indeed so hard that most software developers do not know how to deal with it properly. Please don't feel offended. I myself thought I was quite good in writing concurrent programs at my first job, around the year 2000. But now I recognize I was rather lame about it back then and I'm only very very slightly better in understanding it. Honestly, the part I am really somwhat better at is the understanding of how many of concurrency aspects I still don't understand.

If you believe I am talking nonsense, let me just ask a simple question: have you  every read and understood this fundamental work about concurrent systems by C.A.R. Hoare? I think most programmers have never read it.

Is it so bad and should we all go back to a classroom and study CSP deeply? Not necessarily. I believe that most programmers (here I think of programming as a profession) do not really need profound understanding of concurrency. Unless we do some serious systems or concurrent embedded programming, this skill is really not terribly necessary, because we very often use a frameworks, application servers and such that have standard concurrency mechanisms already built in and the whole trick is to just use it. For many regular development tasks, it is really not necessary to know all odds and ends of concurrency. A proof of this is, in my opinion, simply the proliferation of CPython and Ruby MRI: these implementations use GIL and they do not offer real concurrency, even if someone who uses threads there imagines something different. And yet they are highly popular, successful and useful.

For the remaining 10% of programmers, who really have to have deep understanding of concurrency: they already know that it takes10+ years to develop profound understanding in this area.