Comment by simpaticoder
17 hours ago
It's kind of too bad XSLT didn't take off. It is quite complex, until you compare it to the complexity of what now solves this problem (e.g. a build step with React and webpack and javascript absolutely required on the client-side). As the OP ably demonstrates, XSLT provides a declarative, non-javascript, non-build way to solve the basic HTML component problem. Perhaps a devastating 0-day in V8 will make us really, really want an alternative to the current best practice.
Whilst I can't be certain, I've been hearing that part of Google's want to move away from XSLT is two-fold - and relates to the idea of the security problem.
Partly, there's increasing attacks against XML.
And also, libxml2 has said "no" to security embargoes altogether. [0]
They might well consider there to be 0-days waiting in XSLT.
[0] https://news.ycombinator.com/item?id=44381093
I think the big difference there is that browsers are only responsible for Javascript, which is a big general purpose solution that solves a lot of problems and not just templating/styling XML. Everything else either happens server-side (build steps and webpack) or is userland code that lives inside the sandbox. So there's one task for browsers to do (make a fast and secure Javascript sandbox), and if that works that developers can do whatever they want. Whereas XSLT is not a general purpose tool in the same way, and so needs to be maintained in addition to Javascript and anything else that exists.
If course XSLT can also be used server-side (which is probably a good idea if you want access to the latest features and not some ancient, frozen version of the spec), but browsers aren't the reason that that didn't take off. My guess there is that it's just not an intuitive way of manipulating and templating data in comparison to more traditional HTML templating libraries.
I don't think react is comparable.
React's main thinh is client side reactivity, something that xslt doesn't offer.
A closer comparison would be a templating engine that does statuc conversion to html.
React supports rendering to HTML ahead of time (SSR) which doesn't need any client-side javascript, and this is a prominent feature of most frameworks using React. This feature of React was one of its major innovations over many other front-end frameworks of the time.
> React supports rendering to HTML ahead of time (SSR)...
So does XSLT?
Literally not one person said XSLT can't do it. But in case you missed it somebody did said React can't do it and so XSLT is better.
> build step with React and webpack and javascript absolutely required on the client-side
This was a false statement.
both XSLT and React can be used for this except React can additionally do a bunch of other stuff that does use JS and that XSLT can't do.