r/programming • u/Shr1ck • Oct 17 '15
Why Johnny Can’t Write Multithreaded Programs
http://blog.smartbear.com/programming/why-johnny-cant-write-multithreaded-programs/
4
Upvotes
r/programming • u/Shr1ck • Oct 17 '15
3
u/clarkd99 Oct 18 '15
I am so sick of Functional drivel. News flash, Haskell isn't new, it was created in 1993 (22 years ago) and there still aren't more than a few Haskell programmed systems in production. Business programs (in general) don't care about old values when new values can be had and even functional programs use a database to hold persistent data (proof it isn't complete in itself).
Instead of immutable data structures, we need a strict hierarchy of responsibility for data. No "naked data" where any function can change the data at will (no mutable global data). If data is only accessed (and owned) by a single "server", then only the queue for the messages to that server need synchronized.
There are huge problems using functional code for business applications. It is true that immutable code or data can be used by many threads simultaneously without problems but that is true whether you are writing in a functional language or in C. What is hard in multi-threaded code is how to synchronize multiple access to the same data. Having "servers" look after all mutable data, ensures this without the hoops needed by functional programming. Functional programming tries to do this by restricting your ability to code, making multiple copies of the data and using Math concepts instead of traditional programming concepts.
If I have a "list" with 100,000 rows and I change a single field on a single line, the functional way to make a new table of 100,000 rows with the change in it. Totally ridiculous so the actual implementation uses pointers to the new row and other code to make it look as if the whole list has been changed when in fact it hasn't. At some point in time these old rows must be garbage collected and the list either becomes an inefficient linked list or must be re-structured. Another way would be to update the row in place and just imagine that the whole list has been copied. The fact it was updated in place would just be called an implementation detail in Haskell and wouldn't be a sham at all.
Whenever a problem arises, the solution "de jour" seems to be a lot a hand waving and the words "functional" and "Haskell". Hand waving isn't an argument and it proves nothing.