We all know mutable state can be problematic. But the explanations tend to be abstractions like "reasoning" and "composability". What's a simple *convincing* example in single-threaded code? Having trouble making one that isn't obviously bogus. Is it only a problem at scale?
-
Show this thread
-
Pointers to examples please! We've been promoting this belief for decades, and have built entire languages because of it. Surely there are many concrete examples that support it?
7 replies 2 retweets 9 likesShow this thread -
Here's an example of the "reasoning" argument cc
@tomaspetricekhttps://livebook.manning.com/book/real-world-functional-programming/chapter-1/69 …5 replies 1 retweet 8 likesShow this thread -
Background: I have an idea for making state mutation safer. Next step is to pick motivating examples to be solved in the paper. I'm having difficulty finding something simple and compelling. Pulling on that thread, I can't even find examples motivating pure FP. Huh?
6 replies 0 retweets 3 likesShow this thread -
Replying to @jonathoda
"Can programming be liberated from the von Neumann architecture?" and "Why Functional Programming Matters" have concrete examples (dot product, square-root algo) of why to prefer a functional style. In general, numerical code b/c the underlying math is already pure functional.
3 replies 0 retweets 1 like -
Replying to @wcrichton
My reading is their examples don't show actual *problems* with imperative code. They just show how more *beautiful* the functional code is.
1 reply 0 retweets 2 likes -
Replying to @jonathoda
I think Backus' comparison provides reasonable arguments for the functional version that don't appeal to aesthetic. He argues about nameless-ness, compositionality, generality.pic.twitter.com/b2tpuYT4SZ
1 reply 0 retweets 1 like -
Replying to @wcrichton
Which can all be roughly translated as “more like math”, which is not such a compelling argument if you aren’t doing math
1 reply 0 retweets 1 like -
Replying to @jonathoda
But that's the point, isn't it? FP is about making programming more like math. It's natural to pick examples from the math domain, where the contrast is most obvious. I guess I'm not sure whether you're against the reasoning or against the choice of example.
1 reply 0 retweets 0 likes
For a non-math example, I like UI programming. e.g. jQuery spaghetti where DOM is treated as mutable state separate from the data (also mutable state). Easy to have state mismatches. But React/FRP goes a long way towards solving those issues.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
cognitive psychology. PhD