Threading vs. event-driven - Journal of Omnifarious
May. 16th, 2008
08:06 pm - Threading vs. event-driven
A comrade in arms on the event-driven vs. threaded debate has switched sides and is now a threading advocate. He's been having doubts for awhile but was finally convinced by an article about threaded vs. event-driven approaches in Java. I'm not so sure, though it's clear that some of the long-standing reasons that threaded approaches were bad are starting to go away.
My main complaint about threads is that the concurrency model they represent is too hard for most people to use and requires way more discipline than the average programmer seems capable of.
My secondary complaint is basically that they introduce latency. Every synchronization operation represents a piece of data that has to be communicated between threads. I wrote a long pondering article about threads and latency awhile ago.
One thing I've noticed is that reads are usually much more frequent than updates. This makes things like memcached a good idea. I think of memcached as essentially being NUMA without hardware support.
I think it's clear though that some level of threading is a good idea nowadays.
One interesting thing that Java has done that I think is an overall useful concept is making some data structures immutable so that no locking operations are required to access them. Python does this too.
This is going to require some thinking.