3 ms·
"dice onions" is not a pure function. To be a pure function, you'd need to have the diced onions, but still be able to use the original onions in another contex
by jerf 13y ago
"dice onions" is not a pure function. To be a pure function, you'd need to have the diced onions, but still be able to use the original onions in another context.
The real world doesn't have any pure functions. For one thing, pure functions are timeless; you can view their inputs and outputs as just existing. Of course in the real world it requires computation time to determine what the output is, but that is arguably a characteristic of our universe rather than the function. Trying to understand pure functional programming from a real-world perspective is to start at a grave cognitive disadvantage.
Which rolls nicely into...
"at some level imperative works because it actually is easier to model in your mind. Why does nobody focus on identifying where that level of abstraction may be?"
My opinion is that it certainly is easier to start with imperative, but the problem is that by bringing in all the complexities of the real world you are therefore inevitably building with complicated pieces, and the end result is complicated. Programming with pure functions and trying to isolate the real world is cognitively unnatural... but then again, so is trying to assemble a multi-million line program. That unnatural task is made easier by shearing away the real-world aspects of the function, and deliberately retreating to a much simpler components as much as possible.
My own attempt to elaborate on this theme: http://www.jerf.org/iri/post/2908 http://www.jerf.org/iri/post/2908 The braveclojure.com post grazed my point, but then pretty rapidly left it. My feeling is that people say things like "pure functions are easier to reason about", but still mentally leave that statement classified in "academic brain space" and fail to explore or explain why that's also a very important statement in "practical brain space". (If my mind is broken, it is in that I have refused to build the wall between those two that so many people seem to have.)
- taeric 13y agoRight, I realize it isn't a "pure" function in the direct sense, but at the abstract level it can and often is presented as such. In programming this is trivial to simply return a new one that is diced. (Consider the typical "cons" example, where the trick is to actually return a new list, not modify the existing one. Something that is not exactly intuitive for most folks.) And, I do strongly believe that declarative works best to start. This is mirrored in the physical world where people say to focus on easily specified goals for tasks. (And why my examples started high level.) Similarly, I suspect once you get down to the nitty gritty, it is again nice to be in the declarative realm. It seems that "somewhere between" these layers is where the imperative really belongs. I just don't know where that is. I will probably take a while to digest your post. Thanks for sharing it!