For a long time when people criticize threads, my feeling has been
that (a) they have a point, but (b) threads aren't as hard as they
imply because (c) concurrency is always hard, but mostly (d) thread
critics need to provide better tools for concurrency. I know how to
use threads, and I'm relatively happy with them; I'm quite willing to
look at alternatives, but I don't feel I'm being given very good
alternatives. Convince me with carrots instead of sticks. An
especially poor argument is one that tells me that I'm currently being
beaten with a stick, but apparently don't know it. For people who
think threads aren't a reasonable option for concurrency in Python:
you are simply wrong, lots of people are successfully using threads
for concurrency, and arguments to the contrary are simply delusional.
The Twisted people have tried to provide alternative tools, and they
certainly put their hearts into it, but I just don't think their style
of asynchronous programming is straight-forward enough for the bulk of
programmers. It doesn't provide the gradual learning curve that I
value in Python (regardless of where I personally am on that learning
curve). It certainly looks like Python 2.5 will improve things, but I
don't think the style really elucidates the issues of concurrent
programming particularly well. Concurrent programming introduces
inevitable challenges; a good model guides the programmer, it can't
solve the problems on its own.
The other alternative -- multi-process -- in Python is common enough,
but feels very ad hoc to me. There aren't good tools for sharing data
and communication (or if there are they aren't well enough
publicized). Nor are there good tools for handling multiple processes
in a cross-platform way. I don't use Windows, but I'm not willing to
abandon Windows users by relying on fork. (That doesn't mean we
can't use fork, just that we can't only use fork.)
But, it seems that there might be some progress. I came upon this
post by Jeremy Jones about
concurrency, which led me to this proposal
by Shane Hathaway and this Py-Dev thread.
The discussion seems to have stopped, which is too bad. I hope it
starts back up again.