4 ms·
The biggest strength of React is that it is _just_ a library. You don't need to write JavaScript/TypeScript in a special way (other than limiting side effects,
by curtisf 5y ago
The biggest strength of React is that it is _just_ a library. You don't need to write JavaScript/TypeScript in a special way (other than limiting side effects, which is not a React-specific challenge).
Svelte is not JavaScript. Svelte is a compiler that significantly changes the way code is executed, despite being superficially quite similar. Samples of code that look like they would be equivalent in JavaScript are not equivalent in Svelte.
This can be good for easily reaching a performant version, but it's also a major drawback.
Reconciling these approaches seems quite difficult--maybe the tsx compiler could begin to recognize some common patterns that can be compiled to simple in-place updates. But it would be brittle, since React is more expressive in that it allows lots of code that _can't_ be straightforwardly transformed into efficient in-place updates.
- Graffur 5y agoSvelte is pretty much JavaScript. Which samples work in JavaScript but not Svelte? I would guess that 90%+ of all React written goes through a compile/transpile step in the development process which makes the difference between writing React apps and Svelte apps negligible. I actually went back to React after using Svelte but I think the compile step makes more sense since you're not delivering the library to the end user.
- hitekker 5y agoReact is a framework that doesn't want to admit it's a framework. If you follow its recommendations like Hooks, you have to write your JS a "special way" since React owns your component lifecycle. Put simply, React calls your component, your component does not call React. Your UI code needs to work inside of React, not around it. The relevant and most upvoted HN article on the difference between libraries and framework is: https://www.brandons.me/blog/libraries-not-frameworks https://www.brandons.me/blog/libraries-not-frameworks
- bacro 5y agoExactly!
- wayneftw 5y agoEverything that you can do with Hooks can be done with Class components though. Of course Class components also have a lifecycle that is managed by React. But the existence of a managed lifecycle does not make it a framework either. The article you linked has the answer: > has it established ways of doing things that are mutually-exclusive with other ways those things might be done? The answer here is a solid No in the case of React. Nothing is mutually exclusive, because you choose to use Hooks in one component, a Class in another and you can still use React.createElement elsewhere and straight HTML with vanilla JS even somewhere else.