3 ms·
Either your event handlers are going to be called in a nondeterministic order, or they won't. If they are going to be called in a nondeterministic order, you s
by jerf 11y ago
Either your event handlers are going to be called in a nondeterministic order, or they won't.
If they are going to be called in a nondeterministic order, you still have access control issues and can get yourself into all sorts of concurrency-style problems.
If they aren't going to be called in a nondeterministic order, perhaps because you just have a single cascade of events (open socket, write this, get that, close socket), then in a language like Go you just write the "synchronous"-looking code, and you don't have to write the code as if it's evented. You have only marginally more sharing problems than the event loop.
Raw usage of event loops are a false path. They solve very few problems and introduce far more.
- zzzcpan 11y ago> Either your event handlers are going to be called in a nondeterministic order, or they won't. The order is not going to be completely deterministic, but your whole program operates on explicitly deterministic units of computation that never implicitly execute in parallel (event handlers). This eliminates all of those issues with concurrent memory access. Writing "synchronous" looking code cannot be a substitute, since it makes these units of computation implicit. After which it's no longer possible to distinguish which function call is going to yield, therefore dealing with concurrent memory access is going to be needed, just like in any multithreaded program. So, no, event loops are superior to multithreaded model in almost every way.