Conversation

I feel like pure functional programming is the logical conclusion of test-driven development. Programs with a large side-effect-free core are much easier to test in my experience
14
328
Replying to
Key part to note is that OOP is basically isomorphic to the actor model, and actors do not affect global state. They only have their own private state. I.e. there is no "impurity" because they can only send and receive messages, they can't go and mutate some global shared state
1
Replying to
We might differ on "pure" and "side effect". Check SICP for a great mechanistic explanation. A functional style only has inputs and outputs. In an OOP style you have inputs, outputs and environment. Message passing encapsulates, but it still mutates an internal environment.
2
2
Replying to
Yes actors have internal state. I don't see how that changes anything though. You can test an actor by giving it messages and seeing how it responds. There is no shared state.
2
Replying to and
You can also swap out the runtime to make everything synchronous (i.e. if you send actor A a message, then it *has* to respond to it right away) and you should have no change in how your program behaves.
1
Replying to and
Functions have internal state as well, it's just a different kind of internal state where everything stateful is based on the parameters. E.g. keeping an accumulator as a parameter. I don't see how this is any more side-effect free than maintaining state inside an actor.
1
Replying to
The difference is temporal complexity. To understand a distributed actor you need a Lamport clock. A sequential actor is easier but you are still dealing with "state + time". Most functional programs have a temporal shell, but the core is devoid of time. OOP couples all to time.
1
1