One of my favorite reading passages (in any subject) is the opening to Joe Armstrong’s chapter on concurrency from his first-edition Erlang book. The argument is made that we live in a concurrent world. As hackers, let’s embrace it. It’s a beautiful stanza.
However, after programming Erlang for some time, and thinking differently because of it, I’ve come to realize that most things we do in this concurrent world are indeed sequential.
I submit that although we live in a concurrent world, we as individuals are quite the sequential robots. We are terrible at multi-tasking & this makes thinking concurrently quite unnatural. I think that’s what makes Erlang so challenging, and by that token, rewarding.
The lion’s share of my daily activities are sequential in nature. By the time I open my laptop to code some Erlang, my brain has been reset back to thinking in step-wise terms.
Let’s examine a life-task to be certain.
In brushing one’s teeth, we take out the brush & paste, remove the cap from the paste, apply paste to the brush, turn on the water & start scrubbing teeth in small circles. We rinse the brush, put the cap back on the paste, & put the items back where we got them.
There is nothing to parallelize here, and we get accustomed to dealing with such step-wise tasks as they fill our days, despite the fact that when we walk out the door in the morning, a zillion Rube Goldberg machines are in action all around us.
I was at an Erlang meet-up in the Bay Area recently. Francesco Cesarini was speaking about his new book. At one point, he said something which caught me off-guard: after a while, one starts to code concurrently on the first-pass. I thought that was remarkable! Is it indeed the case that veteran Erlangers are able to do this?
Despite my best efforts, parallelizing Erlang code occurs in the refactoring stage. I guess there is no shame in admitting that. For me, thinking in parallel terms takes an intellectual leap every time I sit down with Erlang. But considering the sequentiality of our days, this makes sense.