3 ms·
They are orthogonal. React (FC) is a declarative _and_ functional approach. The declarative part is where React code describes what should be rendered, instead
by manmal 4y ago
They are orthogonal. React (FC) is a declarative _and_ functional approach. The declarative part is where React code describes what should be rendered, instead of adding/removing DOM elements manually.
The old React is not 100% functional (partially OO), but it still is declarative.
- epgui 4y agoThey're not orthogonal. I believe one is a subset of the other, but at a minimum they overlap.
- manmal 4y agoUsing extremes for both, that would mean there is overlap between languages like Haskell and languages like SQL? (Edited for clarity)
- anonymouskimmer 4y agoI'm a biologist that doesn't understand what's being talked about on this thread at all (a definition of "state", and its relation to other computational parameters would be nice). But I think I can pull an analogy from ecology that might be useful here. When a bird population starts speciating along, say, the arctic circle, you have a line of a bunch of closely related sub-species that can interbreed with the sub-species nearest them. Sub-species 1 ... Sub-species 2 ... Sub-species 3 ... Sub-species 4 ... 1 can breed with 2. 2 can breed with 1 and 3. 2 can't breed with 4 because they are too far apart, but if a 4 came to the territory of a 2 they could breed. Etcetera. Eventually You get a whole circle of interbreedable sub-species as they spread across a circle of arctic latitude around the world: 1 ... 2 ... 3 ... 4 ... 5 ... 6 ... 7 ... 8 ... 9 ... 1 But once you get to that point you find that sub-species 9 and sub-species 1 can't, or won't, interbreed anymore. They are now two entirely separate species despite coming from the same origin and living right next to each other. However none of them can interbreed with a complete separate lineage, such as wolves. TLDR: The overlap is before the extremes, not between them.
- epgui 4y agoWell… I’m not sure how helpful that example is, but yes you could probably find something in common between SQL and Haskell, and on the other hand, no, what I said did not mean that. Look up Graham Hutton’s writings on relations. He has published quite a bit about this, and he knows a thing or two about functional programming.
- manmal 4y agoI think relations are not a precondition for something to be called declarative programming. Most definitions I‘ve found are way broader and generic.
- epgui 4y agoI never claimed they were, and I don't know if they are. But relations are in the category of declarative, and are a generalization of functions.
- epolanski 4y agoReact is neither reactive nor declarative nor functional.
- manmal 4y agoInstead of stonewalling, please explain what React is in your opinion. Edit: I mean it’s called „Functional components“, are they lying?
- threatofrain 4y agoNo, the React team means that they use JavaScript functions as the preferred authoring experience for React components. React components often have side effects & internal state and that's not necessarily a bad thing, notwithstanding strict mode.
- manmal 4y agoFunctional programming doesn’t mean no side effects though. At some point, every language/platform has to have them, or it can’t be used for dynamic inputs. React (can) have referential transparency and up to a degree immutability (yes hooks are not side effect free, but so isn’t the IO monad).