Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: > An interesting point of view: threading is harmful because it removes > determinism from your program. > http://radar.oreilly.com/2007/01/threads-considered-harmful.html
Concurrent programs are inherently nondeterministic because they respond to i/o events that can happen in any order. I looked at the paper cited in that article and it seemed like handwaving. Then it talks about threaded programs being equivalent if they are the same over all interleavings of input, and then goes on about that being horribly difficult to establish. It talked about program inputs as infinite sequences of bits. OK, a standard conceit in mathematical logic is to call an infinite sequence of bits a "real number". So it seems to me that such a proof would just be a theorem about real numbers or sets of real numbers, and freshman calculus classes are already full of proofs like that. The presence of large sets doesn't necessarily make math all that much harder. The test suite for HOL Light actually uses an inaccessible cardinal, if that means anything to you. IOW he says it's difficult and maybe it is, but he doesn't make any attempt to explain why it's difficult, at least once there's some tools (synchronization primitives etc.) to control the concurrency. He seems instead to ignore decades of work going back to Dijkstra and Wirth and those guys. It would be a lot more convincing if he addressed that existing literature and said why it wasn't good enough to help write real programs that work. He then advocates something he calls the "PN model" (processes communicating by message passing) but that seems about the same as what I've heard called communicating sequential processes (CSP), which are the execution model of Erlang and is what I've been using with Python threads and queues. Maybe there's some subtle difference. Anyway there's again plenty of theory about CSP, which are modelled with Pi-calculus (process calculus) which can be interpreted in lambda calculus, so sequential verification techniques are still useful on it. Hmm, I see there's a Wikipedia article "Kahn process networks" about PN networks as mentioned, so I guess I'll look at it. I see it claims a KPN is deterministic on its inputs, while I think CSP's might not be. > Some discussion of the pros and cons of threading: > http://c2.com/cgi/wiki?ThreadsConsideredHarmful This wasn't very informative either. -- https://mail.python.org/mailman/listinfo/python-list