4 ms·
I agree with "hard to reason about and get right" because of the state-space explosion. If you do five atomic things in a single-threaded program, you have six
by notacoward 13y ago
I agree with "hard to reason about and get right" because of the state-space explosion. If you do five atomic things in a single-threaded program, you have six total states to deal with. If you do those same five things in five threads, you have over 200. That's true regardless of whether you're using a naive "locks and blocks" model or a sophisticated functional/CSP/actor model, and splattering that state across multiple stacks/continuations doesn't exactly make debugging easier. People who have done this for a while do apply good programming practices to reduce the number of states and the dependencies between them, but the fundamental problem still remains. Every new state represents a new potential for error, and code that has many error cases is simply harder to write/debug/verify than code that has few.
- VLM 13y ago"That's true regardless of whether you're using a naive "locks and blocks" model or a sophisticated functional/CSP/actor model, and splattering that state across multiple stacks/continuations doesn't exactly make debugging easier." Enormously greater complexity has the side effect of making execution slower. Something to think about. Converting a fast executing and quick to write/debug and reliable single threaded app into an inherently slow executing and slow to write/debug and unreliable multithreaded app needs an extremely good reason outside of the tradeoffs listed above. Those situations do exist, but situations like "I thought it would be fun to put multi-threaded programmer on my resume" happen more often. Its kind of like using "goto". If you don't really understand everything about the topic, its probably a wise choice to always avoid.
- notacoward 13y agoI know this is HN and therefore I'm supposed to disagree, but I don't see how I would. Yes, there are a lot of people writing multi-threaded programs who shouldn't be, either in the sense that they don't need to or that they're not qualified. The problem I see with the OP is that it's giving advice based on assumptions common in the tyros' environment but much rarer for people who actually do need to write multi-threaded programs. The claim that "it's not hard" doesn't hold water. Dabbling's never hard.