3 ms·
No, React exists because there was a need for a template engine that’s easy to use. There is still no global standard for templates. Just like mustache, Twig,
by wayfinder 3y ago
No, React exists because there was a need for a template engine that’s easy to use.
There is still no global standard for templates.
Just like mustache, Twig, Java Server Pages, Jinja, ERB… every language has this problem. You have a bunch of components written in HTML and you need to mix and match them together in a bigger unit. React+JSX let you do that easier than appending DOM components. Before React, you’d use different libraries that did what React did.
The ONLY major language I can think of that has templating baked in is PHP.
- Joeri 3y agoHTML has built-in templates now, and custom elements (web components) provide composability. If the built-in templating is not quite powerful enough (it has no logic or variables) there’s developit/htm which is basically JSX but parsing in the browser. React is still easier, but it comes at a maintainability tax because you have to keep upgrading to new react versions and port to new react wrapper framework versions if you want to keep a codebase in active development. Vanilla web development has no such problem because web standards remain backwards compatible. For a small project where I don’t care about SEO / server-side rendering I absolutely prefer vanilla web dev over React now.
- wayfinder 3y agoYes, it does! But while I have not used them yet, the approach used by them (via SGML tags) is not new and many libraries / XLST have done it before in the past 20+ years and I find the approach usable at best. It's too verbose for my taste and it never really caught on, and I find it hard to think that it would catch on this time.
- nicoburns 3y ago> React is still easier, but it comes at a maintainability tax because you have to keep upgrading to new react versions and port to new react wrapper framework versions if you want to keep a codebase in active development. There has been one breaking version of React (the recent React 18) in it's 8 years of history. Upgrading React versions is a non-issue. Wrapper frameworks like next.js can come with a much higher maintenance cost, but you don't need to use those to use React (and I think most people don't).
- radlad 3y ago> The ONLY major language I can think of that has templating baked in is PHP. Depends on what you mean exactly. For example, Go ships with templates. They don't mix HTML markup and Go code directly though.