Andrei Dascalu
1 min readApr 27, 2021

--

I’ m talking about state because you brought in a misconception. And you seem plenty confused about what you want to argue.

Mutable state isn’t the same as shared state. Mutable state is a state that changes outside of functions. Data that may come from dB, files, persistence, etc. FP doesn’t use it as-is anywhere and everywhere. It has nothing to do with concurrency and whatnot.

Shared state is a different thing. Shared state does affect concurrency and it has nothing to with your development style. When you work with concurrency and state you’d better use a platform that allows communication between concurrency construct.

How a function knows what to do? By the way it’s programmed. A function takes parameters and does something. It does not need to be attached to state. It receives data and returns data. If you do need to directly alter data inside the function you can optionally pass a pointer, but it’s a conscious decision (whereas in OOP you always have an implicit pointer to data).

You don’t talk about functions, you talk about methods. Methods are attached to objects and chmge the state of the object. A function has the same outcome whether called once or 100 times on the same data, whereas a method since it alters the attached object instance. You need to care about those sorts of things.

--

--