3 ms·
Why is it that the world today is convinced it is "mutable" state that is the root of all ills? Is it difficult, yes? Should it be completely abandoned? I'm
by taeric 12y ago
Why is it that the world today is convinced it is "mutable" state that is the root of all ills? Is it difficult, yes? Should it be completely abandoned? I'm not so sure.
Granted, I just recently managed to butcher[1] what is effectively an "anti-immutable" algorithm. Seeing that there have been parallel versions of this algorithm implemented successfully, I can't bring myself to throw out that tub yet. Did they do this by removing the mutable nature of the algorithm? Not to my knowledge. No, instead they kept this mutable tool and built on top of it with something that is basically message passing.
That is, instead of throwing out the mutable tools we have, you can also segment the work you are giving out. This isn't exactly novel, either. Consider anyone planning the festivities of any major event. Timelines and work plans are par for the course. Yet, we often try to make things "just work" for us "in time" in programming.
Still, if you want one "true" abstraction. My bet is on Channels. :)
[1] http://taeric.github.io/DancingLinks.html http://taeric.github.io/DancingLinks.html
- kaoD 12y ago> Should it be completely abandoned? I'm not so sure. Nobody is trying to abandon mutable state (or nobody should, at least). If we abandoned it, our computer would be a static screen where nothing would happen. Functional programmers embrace mutable state, but only where it's needed! If the program is faster or cleaner using mutable state, why not? Check some of Clojure's mutable constructs as an example: http://clojure.org/vars http://clojure.org/vars | http://clojure.org/Refs http://clojure.org/Refs | http://clojure.org/Atoms http://clojure.org/Atoms | http://clojure.org/transients http://clojure.org/transients
- taeric 12y agoThe dream is typically, as I understand it, that the compiler can figure out all of the places where mutable state is required. Don't get me wrong, I realize most folks are more pragmatic than they are dogmatic. However, I also know that all of my coworkers and most folks I have talked to are obsessed with "persistent" collections. Often touting them as some sort of must have for reliable multithreaded work.