3 ms·
> React started to move away from OOP and more towards FP Please don't confuse what you see in React with FP! It is not FP. See: https://mckoder.medium.com/wh
by petilon 5y ago
> React started to move away from OOP and more towards FP
Please don't confuse what you see in React with FP! It is not FP. See:
https://mckoder.medium.com/why-react-is-not-functional-b1ed12a41323 https://mckoder.medium.com/why-react-is-not-functional-b1ed1...
- shawnz 5y agoIt seems to me like this is just arguing that react is not purely functional. That doesn't disagree with what the other poster is saying which is that react is moving towards a more functional style.
- petilon 5y ago> more functional style What does "functional style" mean here? Is C language a functional programming language? It lets you write functions, pass functions around as parameters, and so on. So, is C functional?
- shawnz 5y agoWithout closures it's a stretch, but yes I would say you can write in a functional style in basically any language.
- petilon 5y agoI would argue that other than eschewing classes for bare functions, there is nothing functional (as in "Functional Programming") about React or hooks. Simply removing classes and calling it "functional" is a stretch.
- shawnz 5y agoThey didn't call it "functional" though. They simply said that it is more functional than it was previously. If you reserve the word "functional" for only the most idealistic implementations of those ideas then it just makes it unnecessarily difficult to describe things which are in the middle. Basically, I think "functional" is more of an axis than it is a circle on a Venn diagram.
- petilon 5y ago> They didn't call it "functional" though. See [1] where they say "if you’re a functional programming purist and feel uneasy about React relying on mutable state as an implementation detail, you might find it satisfactory that handling Hooks could be implemented in a pure way using algebraic effects". [1] https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 https://medium.com/@dan_abramov/making-sense-of-react-hooks-...
- agumonkey 5y agonever mutate anything and just compose functions and your C is functional
- _v7gu 5y agoEffect, State etc are monads, and 'use' is do-notation that lets you use them in an imperative style. What's not functional about that?