I previously had a blog post on thread-safe programming, where I said I wanted to do it, and that I know how mutexes work and I should start from there. That post has been wiped off the face of my blog.
I’m not going to do low-level parallel programming for the foreseeable future. I came into some free time over the last month and did a fair bit of reading. One of the books was “C++ Concurrency in Action” by Anthony Williams. I figured I’d benefit from some theoretical knowledge of parallel programming, and I’ve been interested in it for a long time, primarily due to the easy application for it when doing time-series analysis.
That book scared me. In my ignorance I thought that a mutex over a shared data-structure would be fine. Nop. That book lists a gajillion different ways a mutex could still result in your program rolling over and giving up. Scary stuff. It didn’t help that all the examples were in C++, but I’m quite sure that I’d still find it a very complex matter even if the examples and use-cases and pitfalls were in Ruby. I’ve not looked at the later chapters yet.
The thing that I’m taking away from this is to use language features whenever I can. Its great if you are using something like Erlang or Clojure, which were built with parallelism in mind. If language-level features aren’t an option, just use a well-tested and widely-used library. I’m not doing my own parallel programming ever. What a terrible idea. Fortunately I didn’t build anything before reading that book (And learning things the difficult way). That was a close call.
Leave a Reply