Re:Alan Kay's: Why is FP seen as the opposite of OOP rather ...
by elcritch on Friday March 23, 2018 @04:03AM
(#16655964)
Aside from the virtual Time idea, it strikes me as very similar to how Elixir programs work. :-) Well Erlang as well but the Elixir language design encourages maps and typed maps which resemble objects more so. It’d be neat if you could re-wind your entire app with a virtual time (like clojure
Scripts debugging setup).
Re:Alan Kay's: Why is FP seen as the opposite of OOP rather ...
by shalabhc on Friday March 23, 2018 @12:48PM
(#16660010)
Right - Erlang does the 'objects and messaging' idea quite well. I'm not sure if all effects of sending a message to an Erlang process are 'isolated'? E.g. could a process write to the disk directly or would that also be manifested as a message?
The result of having a time base universally embedded in all messages and object histories is that there is no 'global' system state. You can only look at the system at a specific snapshot, even while it may continue to evolve.
Re:Alan Kay's: Why is FP seen as the opposite of OOP rather ...
by elcritch on Monday March 26, 2018 @02:03AM
(#16676951)
Yes, actors in BEAM can modify files and there's a small bit of local state which can be set without messages (the process dictionary). However, much like Haskell you'd still need some point where real side effects could occur. It'd be possible to do all file actions via specific actors using messages which could then be modified to support "time-travel".
Re:Alan Kay's: Why is FP seen as the opposite of OOP rather ...
by shalabhc on Monday March 26, 2018 @03:38PM
(#16681781)
Right - you'd also need object 'histories', so handling every message in effect produces a new version of the process.
Re:Alan Kay's: Why is FP seen as the opposite of OOP rather ...
by mpfundstein on Friday March 23, 2018 @08:40AM
(#16657386)
Thanks a lot for the virtual time article. It was an awesoem read. Do you have any more of those?
Re:Alan Kay's: Why is FP seen as the opposite of OOP rather ...
by shalabhc on Friday March 23, 2018 @01:40PM
(#16660620)
Hmm, not sure what specific aspect you're looking for but here's some related stuff:
For 'managed time' ideas in the 'small', see https://www.microsoft.com/en-us/research/publication/program... and http://www.vpri.org/pdf/tr2011001_final_worlds.pdf
There seems to be more in database systems with overlapping ideas, e.g. see Datomic (https://www.infoq.com/articles/Datomic-Information-Model) and CRDTs (https://en.wikipedia.org/wiki/Conflict-free_replicated_data_...).
IIUC one idea here is to apply the concept of 'reliable function' into the object oriented world:
> For example, this would allow “real objects” to be world-lines of their stable states and they could get to their next stable state in a completely functional manner.
So [object_in_state_A + message_Y] => [object_in_state_B] is some change in an object as a result of receiving a message. This 'transformation' is functional i.e. always produces the same result, given the same input state and message (similar to the pure function concept in FP). Also, the transformation 'rules' only see exactly state_A and not some invalid in-between state. This allows reasoning about these transformations clearly. The object is a history of object states: [object_in_state_A -> object_in_state_B -> object_in_state_C] etc. Note only the 'stable' i.e. valid states are exposed by the object (they're unavailable during transformation) so any view is consistent.
Now to compose many such objects into larger system that is also consistent, see the Virtual Time idea (David Jefferson) or the earlier Pseudo Time idea (David Reed). An overview of Virtual Time is here: https://blog.acolyer.org/2015/08/20/virtual-time/.
The rough idea is that all messages are stamped with a virtual timestamp - so any receiver can determine the exact order in which to apply the incoming messages. The whole system moves forward in virtual time, correcting for any out-of-order delivery - the real time of each message isn't important anymore.