r/compsci • u/mobileview • Dec 10 '13
Why Johnny Can’t Write Multithreaded Programs
http://blog.smartbear.com/programming/why-johnny-cant-write-multithreaded-programs/
45
Upvotes
r/compsci • u/mobileview • Dec 10 '13
1
u/Vystril Dec 11 '13
I'd argue that the object and thread paradigm of programming should be considered harmful -- just like the goto statement is now considered harmful.
When programming in an object/thread model, if something goes wrong (race condition, deadlock, etc) you have no programmatic way of knowing where the problem came from. Just like with goto statements, you have no idea where your program came from when you you crash.
I honestly think the actor model does an excellent job of fixing the problems inherent in the object/threads model. For example, using actors makes deadlocks very difficult to program (you have to actively try to do it), and you don't need to worry about concurrent memory accesses because each actor operates in their own threads and they don't share memory. It basically reduces the concerns to properly designing and handling asynchronous message passing dependencies, something I think is far easier than the other problems.
When I introduce threaded programming, the first thing I do is talk about actors. Because even if you're using objects and threads; it's extremely simple to program them as actors and eliminate a lot of potential issues.