6 ms·
Counterpoint: React is no less opinionated, fast, or has less of a DSL than Vue. Opinionated: React is a library written for a language that is not JavaScript
by mediumdeviation 9y ago
Counterpoint: React is no less opinionated, fast, or has less of a DSL than Vue.
Opinionated: React is a library written for a language that is not JavaScript (the first prototype was written in OCaml). It demands immutability, which JS has no native support for. it wants you to use FP, but JS natively has little support for FP both in its standard library and syntax. FP only looks good in JS if you've never used a real FP language.
DSL: JSX is a DSL - I can't remember the last time I've seen someone use && as a poor man's if statement, or ternary statements dozens of lines long until I started writing JSX. JSX is neither idiomatic JavaScript nor HTML.
Fast: Performance benchmarks (which admitted are flawed as they can't capture real-world usage) show that React and Vue have similar rendering speeds. Vue's computed property dependency tracing means that a lot of the performance optimizations which require manual work to enable in React (manually memoize expensive computation, shouldComponentUpdate, PureComponent etc.) are handled automatically by the framework.
- root_axis 9y ago> it demands immutability, which JS has no native support for. You don't need native support, just don't mutate state when calling setState, which is a pretty simple rule to follow. > it wants you to use FP, This isn't really true. React components are often written as ES6 classes and stateless functional components are only functional insomuch as they are literally just a function. I can't think of any advanced FP concepts that are necessary for idiomatic React. > JSX is a DSL Technically true, but in practice it is just ES6 and the HTML side of JSX so closely resembles actual HTML that the DSL criticism loses most of its meaning. > I've seen someone use && as a poor man's if statement It may be a code smell, but it's certainly valid JavaScript and not a technique that could be correctly described as contributing to the idea that JSX is a "DSL". Also, you don't have to do that, just use an if statement or a ternary operation to compute your result outside of the JSX block and reference the resulting variable in the template part of the render function.
- shaneos 9y ago> React is a library written for a language that is not JavaScript (the first prototype was written in OCaml) This is incorrect. React was written first in JavaScript in the Facebook Ads org, to be used in the Ads Create Flow application. Jordan's dive into OCaml came later, which is why we now have Reason many years later.
- tomelders 9y agoOn JSX... ok, that's not Javascript. Nor is it HTML. But it absolutely the right tool for the job, if that job is creating component based web applications. JSX is such a perfect fit that I take umbrage with people who sneer at it. What better way is there to bridge the gap between the DOM and Javascript? And JSX isn't exclusive to React anymore. That's testament to how useful and practical JSX is. I can see JSX becoming bona fide standard like HTML.
- mlsarecmg 9y ago> DSL: JSX is a DSL - I can't remember the last time I've seen someone use && as a poor man's if statement, or ternary statements dozens of lines long until I started writing JSX. JSX is neither idiomatic JavaScript nor HTML. Nothing in React forces you in any way to use ternaries. You can do all your pre-calculation in the render method, and if that's your style you would most certainly do that. const Say = ({ reverse, text }) => { if (reverse) text = text.split('').reverse().join('') return <div>{text}</div> } <Say reverse text="hello" /> Btw, Vue isn't any different here, you use ternaries there as well, only that it's severely limited as you couldn't refer to other components, the template is a dead string after all: template: ` <li v-for="(item, index) in items"> {{ index > 2 ? item : item.split('').reverse().join('') }} </li>` > It demands immutability, which JS has no native support for. It doesn't do that at all. Even redux uses plain shallow copies. Vue on the other hand does exactly that, it uses observables which aren't supported in most browsers. Reason why as of version 3 you will maintain two codebases (one for IE11 and prior, one for evergreen) since Proxies aren't back-compatible. > it wants you to use FP Not at all. It is unopinionated.