5 ms·
Resolving the Time Paradox Implied by Functional Programs
- Smaug123 6y agoEven "fold : (state -> a -> state) -> state -> a list -> state" implies this resolution. The function is pure, but in some sense it assigns a "program state" to every element of the list. Having created a time evolution of the computation, we then essentially throw away all but the last. For optimisation reasons, of course, we don't actually generate the entire intermediate list of program states.
- lisper 6y agoThe fundamental problem is the opposite one: it's the world that throws away intermediate states, and that happens whether you want it to or not. Unfortunately for FP afficionados, physical reality runs with autocommit set to True.
- lmm 6y ago> it's the world that throws away intermediate states, and that happens whether you want it to or not. Unfortunately for FP afficionados, physical reality runs with autocommit set to True. This fact is unfortunate for OO aficionados who try to build programs by modelling the real world, because it leads them to build programs with the same problem. Whereas FP aficionados realise that even though there's no "undo" in the real world, we can enable it in our programs.
- chrisweekly 6y agotouché!
- notduncansmith 6y ago> physical reality runs with autocommit set to True Only from the inside ;)
- andrekandre 6y ago> We may attribute normal object-oriented semantics to the above gif, concluding that “a cat is dancing.” However, we may also attribute functional semantics, concluding that “a cat has arms above its head on frame fᵢ.” in that case, without adding impure statefulness, how does one differentiate between "a paused frame is being displayed" and "an intermediate frame of a playing video is being displayed" -- then at the end, the example from elm looks great, but i see lots of impure state being generated (browser, model) or am i missing something?
- jbmilgrom 6y ago> in that case, without adding impure statefulness, how does one differentiate between "a paused frame is being displayed" and "an intermediate frame of a playing video is being displayed" A "paused" frame could be represented like Fi, Fi+1 ... Fi+N, etc; for every moment i..(i+N), F remains the same and is thus "paused." The thing that's tough to wrap your head around is our language is rooted in object-orientation however. "Pause" is less of a meaningful term when time is discretized. See also https://softwarefordays.com/post/fp-as-a-scientific-revolution/ https://softwarefordays.com/post/fp-as-a-scientific-revoluti...
- jbmilgrom 6y ago> then at the end, the example from elm looks great, but i see lots of impure state being generated (browser, model) or am i missing something? All functional programs (even if written in Haskel) have side effects - the CPU only has a certain amount of registers that can be used, for example, so any nontrivial program will be constantly overwriting them. That elm program however only exposes pure functions in user land, just like with a Haskel program
- andrekandre 6y agothanks for the reply i guess what i was thinking was, if there was a ui, with a play/pause icon, and playing the video should cause the play icon to switch to a pause icon (because video is now "playing" so we want to be able to click it and "pause" the video) how do we represent that in a purely functional way? since at any "timeless" instant, t1 vs t2 is just a frame1 vs frame2 issue at the language level (?), how in a purely functional world, would we determine that video is indeed playing and that icon should be swapped while playing vs not? does user-interactive systems imply that there must inherently be some impurity?
- togaen 6y agoThis feels like a rehash of Zeno’s arrow paradox.
- nudpiedo 6y agoNot sure what the point of the article was, it makes hard easy concepts. It would have been easier by properly explaining common functional programming patterns such as event data stores, or even more popular ones used in the javascript world like vuejs store or redx etc.