5 ms·
If you are at war with your technology, your codebase will look like a battlefield. React and Redux require a functional, reactive mental model. If you approach
by bayesian_horse 5y ago
If you are at war with your technology, your codebase will look like a battlefield. React and Redux require a functional, reactive mental model. If you approach it with an imperative mindset, you'll get a mess of a codebase.
Unfortunately the popularity of React means it is used by people who know neither Javascript nor FP very well. And the popularity of Redux is even worse.
In my opinion people should stay away from Redux until they know and understand intuitively why it is necessary. Until then, use the useState and useReducer hooks, then maybe something like "Zustand". When you start using Redux, use Redux Toolkit.
- jhgb 5y ago> If you are at war with your technology, your codebase will look like a battlefield. That almost sounds like a criticism of people who developed React and Redux and went to war against their browser APIs.
- bayesian_horse 5y agoNot really. Redux doesn't even touch Browser APIs as far as I know. React uses a virtual DOM to avoid DOM unnecessary manipulation, which is slow and error prone. DOM manipulation could be seen as a week point of browsers, and by avoiding it, React is actually a very good ally. Javascript is a dynamically typed language and offers quite a bit of functional programming functionality itself. React and Redux use that to their advantage, rather than insisting everything be modeled by classes.
- jhgb 5y ago> React uses a virtual DOM to avoid DOM unnecessary manipulation, which is slow and error prone. While it may be the case that DOM is far from perfect, React is hardly the only way to avoid it. Even if for your use case avoiding DOM manipulation is necessary (which I strongly suspect is not true for like 95% of people who use React as the framework du jour), there seem to be significantly better thought out approaches, like for example Svelte, if you absolutely have to go down the "let's turn our browser workflow into a C-like one" road and churn out an opaque blob of code as a result. That also avoids unnecessary DOM manipulation, but unlike unnecessarily duplicating browser data structures is at least somewhat elegant, just like compilers are considered elegant compared to interpreters. > React and Redux use that to their advantage, rather than insisting everything be modeled by classes. Sure, but Javascript is not even based on classes. It traces its heritage back to Self which doesn't even have classes.
- bayesian_horse 5y agoAvoiding direct DOM manipulation is a benefit in almost any case. Virtual DOM is now at the root of most popular UI frameworks libraries, including Vuejs and Angular, also less popular WASM ones like Blazor(C#) or Percy (Rust). I do remember writing complex JQuery components. React felt like a liberation for me...
- jhgb 5y agoBut because JQuery was bad doesn't mean that React was the answer. That would be a false dichotomy to make.
- guntars 5y agoInterpreters are considered elegant, too. For example, Lua is a great little language and it runs everywhere precisely because it's interpreted.
- jhgb 5y agoSure, there are many elegant interpreters. I'm not sure that patching DOM from the changes in a redundant data structure is one of them. Even Blink's idea to instead pull browser's own DOM into Javascript definitely looks saner to me.
- bayesian_horse 5y agoIt's not a redundant data structure if you need it to figure out the necessary changes. You are free to choose other approaches for your frontend projects. Just don't expect to get hired into larger teams easily.
- jhgb 5y ago> It's not a redundant data structure if you need it to figure out the necessary changes. And why exactly can't you "figure out the necessary changes" without it? > Just don't expect to get hired into larger teams easily. Honestly, I see that as a win-win.