3 ms·
They are not. Extending JavaScript with an XML-like syntax that transpiles down to composable function calls feels far more natural. In contrast, extending HTML
by gloosx 1y ago
They are not. Extending JavaScript with an XML-like syntax that transpiles down to composable function calls feels far more natural. In contrast, extending HTML with a template syntax feels limiting and less intuitive in practice — thats why these frameworks are unlikely to ever reach the same level of traction as React.
- kode95 1y agoWhat feels more "natural" is likely to be influenced by what you already know. I've always felt that JSX felt unnatural and Vue's and Svelte's way of doing it feels more natural.
- gloosx 1y agofair — what feels natural usually depends on what you are used to. But even aside from preference, JSX aligns directly with how JavaScript itself works. You are not learning a new templating DSL — you just compose functions. That conceptual unity is what makes React approach click for for so many.
- jmull 1y ago> JSX aligns directly with how JavaScript itself works... Why javascript, though? That preference, again, seems based on what you’re used to. The actual goal is to manipulate the DOM based on state changes using a declarative representation. Javascript seems more like something that was available rather than a good fit. (In fact, they felt like it was a bad enough fit that JSX had to be added to the mix.) Setting aside any particular framework, HTML seems like a better fit to me… it’s inherently declarative and, of course, has a well understood, well supported relationship with the DOM. Extensions to bind state can be pretty well contained.
- Alex-C137 1y agoHard disagree. React is only popular because large companies made it so. There are few things that React is inherently better than Vue and none of them are its bundle footprint, page load speeds, nor the average time to learn one or the other. Subjectively I am extremely in opposition to the fact that XML anything with composable functions is more intuitive than HTML templates by any stretch of the imagination.
- gloosx 1y agoI get your point, but to me it is about composition, not popularity. Writing UI as pure functions of state feels far more natural — recursion, higher-order patterns, dynamic layouts, all come easily because React is just JavaScript. In Vue or Svelte, recursion and logic feel bolted onto an HTML templating layer, which makes complex patterns less fluid.
- recursive 1y ago> Writing UI as pure functions of state feels far more natural That makes sense, but that's not what react does. Components are functions of their "prop"s. The rest of the state comes from a memoized cache in a fiber. Which fiber? That's determined from a reconciliation algorithm. Does it do the right thing? Usually. You can tell if it's "a function of state" by whether the state is in the parameter list.
- jakubmazanec 1y ago> React is only popular because large companies Hard disagree. React became popular because it was much better than its predecessors like Backbone, and also better than its contemporaries like the first Angular. I was still learning JavaScript, when I was doing a browser app for my thesis, and I used Backbone as a framework. Awful experience, using React was much more intuitive. While Backbone was imperative, React was declarative, with composable components, no custom HTML template syntax. Using React made web development fun for me. > extremely in opposition to the fact that XML anything with composable functions is more intuitive than HTML templates And I hate HTML templates. I think there are just two groups with different preferences and therefore it's somewhat useless to argue about this stuff.
- Alex-C137 1y agoNone of this refutes that fact that it was created and pushed by Meta nor explains why it remains popular when there are "better" alternatives by nearly any objective measurement. HTML template frameworks have gotten significantly better since your thesis over ten years ago, Vue.js being the primary one that quickly followed React less than a year after it came out. I also used backbone and knockout.js professionally and, while I agree I definitely prefer React over those, it doesn't explain why React remains popular. I like to argue about it because I like knowing why people think the way they do about React. I'm a long-time React hater and still look for ways to change my mind, so there's a point for me I guess?
- paulhebert 1y agoIt feels much more natural to me to extend HTML for rendering HTML than to add an xml like syntax in my JavaScript. Why would I choose to write html in js over writing it in html?