It's rather you carry your state with you, from function to function. Sometimes, a class is nicer, and I am primarily a FP developer.
Why not both? If the methods of a class don't mutate the state in place you're still dealing with pure functions.
A class that doesn't mutate state? So it doesn't encapsulate its own data? Well what's the point of classes then? That's just procedural programming with extra steps
Instead of += which returns nothing you have + which returns a new instance. It's how things like jax work - jax even explicitly forbids in place assignment. Classes become mostly about keeping things organised and syntactic sugar.
Ah, your code does not run in the real world then?
The one thing my anarchist friend and I agree on.
Something something when you touch the functional developer's PROstate
gj. You’ve made a Postgres middleware
What are you talking about? Functional programming has state still, otherwise you wouldn’t be able to hold a website state. It emphasizes not mutating the state, but things like Redux exist specifically for functional state management.
The point is to isolate the states and minimize their propagation. You want any statefulness to be confined into predictable, explicit boxes in a way that doesn't affect the purity and the soundness of the rest of the code
Yes, state should be hyperlocalized and inaccessible to any process that doesn't need it. Global state is maddening to me.
Yes, it is best to make state immutable in functional programming, but OPs meme is just wrong. Functional apps are still stateful, they just don’t mutate the state.
The state should be isolated and most of the work you will do is on pure functions without state. Yes, some state still exists, but you don't work with it constantly. It's not at all unreasonable for one to think to themselves "no more state" when doing FP because the main work is state free.
That, or OP wants controversy to get the post going.
How can you have a state when there is no mutable cell?
-laughs in Haskell
No but seriously, there is no hidden state since many "true" functional languages don't want you to reassign variables and therefore you can't just put the state in a hidden private member and forget about it.
Brings me to my current default style - functional oop. It's kinda the most natural style when you use machine learning libraries like torch. As long as a method doesn't mutate the state of the objects it's still a pure function, python even makes that explicit with the self parameter.