4 ms·
Next article in the series: now that you know about the dangerous/complicated primitives, don't ever touch them again. Instead use the high-level safe concurren
by bmn__ 7y ago
Next article in the series: now that you know about the dangerous/complicated primitives, don't ever touch them again. Instead use the high-level safe concurrency/parallelism mechanisms in your programming language: futures/promises, nurseries, channels, observers, actors, monitors. Ideally, these should be built-in, but a library whose API composes well into most programs will also do.
Data races can be statically removed by carefully restricting certain parts of the language design, see Pony. https://tutorial.ponylang.io/#what-s-pony-anyway https://tutorial.ponylang.io/#what-s-pony-anyway
Bonus: learn aspects of deadlocking by playing a game: https://deadlockempire.github.io/ https://deadlockempire.github.io/
- swsieber 7y agoSee also Rust for the data races portion. Though IIUC Pony is also supposed to prevent deadlocks.
- Groxx 7y agoThere are no locks in Pony, so yes: no deadlocks. (livelocks / other kinds of "lack of progress" are of course still possible tho)
- rrss 7y agoSomebody has to maintain the operating systems and a metric ton of system software written in C. It cannot be magically all switched to Pony or Rust overnight.
- throw51319 7y agoI am just getting into concurrency. Is there any point to use threads or forkjoinpool in Java anymore? Should you always just use CompletableFutures and Suppliers?
- closeparen 7y agoI disagree, first you need to program a few toy projects with the dangerous primitives, to really internalize how tricky they are. It's because of my concurrent C homework assignments that I was able to really appreciate Go's channels in my first internship.
- keymone 7y ago“Never touch them again” means don’t reach for those primitives when higher level tools are available. Learning about them is fine. It’s like with cryptography - don’t roll your own solutions just because you know what xor is. You’ll fail miserably.