Live data from Hacker News

The time is right for a DOM templating API

justinfagnani.com

221–230 of 256 posts

Re: The time is right for a DOM templating API

#221

Earlier quoted context omitted.

> Hard not to laugh out loud at "We know what good syntax for templating looks like." First of all, it's not very nice to laugh in the face of someone advocating for progress on the web platform, which benefits everyone. Second of all, yes we do now know what good syntax for templating is, it's basically jsx (and I'm saying this as someone who's really not a fan of React). It took the whole web by storm, it's been ad…

> yes we do now know what good syntax for templating is, it's basically jsx (and I'm saying this as someone who's really not a fan of React). It took the whole web by storm, it's been adapted for all kinds of frameworks, and it's undeniable that all js templating systems converged towards common attributes: templates-as-expressions, composition via nesting and control flow with just javascript (instead of specific te…

> JSX really isn’t that great. Sometimes it feels like most React devs don’t know how to write a for loop or if statement because they mostly use map(), ternaries, and short-circuiting, which are not very ergonomic compared with markup-based approaches.

I'm the last person to vouch for React and the horrors it has inflicted upon web development, but the one thing it definitely got right compared to Angular (and Vue) is the use of JS for control flow, rather than fake attributes and whole new language.

Re: The time is right for a DOM templating API

#222
post #221

Earlier quoted context omitted.

> yes we do now know what good syntax for templating is, it's basically jsx (and I'm saying this as someone who's really not a fan of React). It took the whole web by storm, it's been adapted for all kinds of frameworks, and it's undeniable that all js templating systems converged towards common attributes: templates-as-expressions, composition via nesting and control flow with just javascript (instead of specific te…

> JSX really isn’t that great. Sometimes it feels like most React devs don’t know how to write a for loop or if statement because they mostly use map(), ternaries, and short-circuiting, which are not very ergonomic compared with markup-based approaches. I'm the last person to vouch for React and the horrors it has inflicted upon web development, but the one thing it definitely got right compared to Angular (and Vue)…

JSX is as much a new language as Vue’s templating. JSX extends JavaScript syntax; Vue extends HTML syntax.

If you’re working on generating markup, it makes more sense to do that at the markup level than constantly switch between markup and imperative JavaScript.

It might use JavaScript for control flow, but does it really count when it uses it in a way that is not idiomatic at all? It’s not idiomatic JavaScript to use map instead of for everywhere, and it’s not idiomatic JavaScript to use ternaries instead of if everywhere. Writing JSX looks very different to writing normal JavaScript.

Re: The time is right for a DOM templating API

#223
post #221

Earlier quoted context omitted.

> JSX really isn’t that great. Sometimes it feels like most React devs don’t know how to write a for loop or if statement because they mostly use map(), ternaries, and short-circuiting, which are not very ergonomic compared with markup-based approaches. I'm the last person to vouch for React and the horrors it has inflicted upon web development, but the one thing it definitely got right compared to Angular (and Vue)…

JSX is as much a new language as Vue’s templating. JSX extends JavaScript syntax; Vue extends HTML syntax. If you’re working on generating markup, it makes more sense to do that at the markup level than constantly switch between markup and imperative JavaScript. It might use JavaScript for control flow, but does it really count when it uses it in a way that is not idiomatic at all? It’s not idiomatic JavaScript to us…

The difference is that JSX is using control flow from an actual programming language, whereas Vue is shoehorning control flow into declarative markup. This is the single reason React won the frontend framework market: they got the templating right.

PS: in modern JavaScript, using map rather than for loops is more idiomatic!

Re: The time is right for a DOM templating API

#224
post #96

Earlier quoted context omitted.

> It’s worth noting this was written by by one of the people wrecklessly barging forward with half-baked specs that introduced significantly more problems than they solved, pushed a "solution" that requires 20+ new web specs to barely do all the things user-space is already doing while completely ignoring and gaslighting anyone who wasn't 100% on board with what they were doing. Safari argued that there should be a d…

Web components were such a big disappointment. 200% the complexity for 20% of the functionality. Everything coming out of that area seems to be hideously over-engineered while failing to solve the problems people wanted them to. My feeling is that they were focused on designing something that is aimed at building form controls, not the kinds of components web developers use in practice. They are designed to make brow…

It should have been possible to declare and use simple web-components - which use a template and a CSS class - without any Javascript.

Re: The time is right for a DOM templating API

#225

Earlier quoted context omitted.

Web components were such a big disappointment. 200% the complexity for 20% of the functionality. Everything coming out of that area seems to be hideously over-engineered while failing to solve the problems people wanted them to. My feeling is that they were focused on designing something that is aimed at building form controls, not the kinds of components web developers use in practice. They are designed to make brow…

Im not sure what you're referring to, they seem pretty straightforward to me. Create a class that extends HTMLElement, implement stuff in connectedCallback and attributeChangedCallback. Return a list of attributes in static observedAttributes. Or use some extended class if you want, there are plenty and they're easy to create your own.

You mean other than the 20+ web specs they added to platform (often to "fix" problems that they themselves introduced and/or that no one else has)? https://w3c.github.io/webcomponents-cg/2022.html (this list appeared after half a dozen or more specs had already been rammed through)

Or that their mere existence infects nearly every spec in existence delaying and needlessly complicating actual useful specs like Scoped CSS?

Re: The time is right for a DOM templating API

#226
post #96

Earlier quoted context omitted.

> It’s worth noting this was written by by one of the people wrecklessly barging forward with half-baked specs that introduced significantly more problems than they solved, pushed a "solution" that requires 20+ new web specs to barely do all the things user-space is already doing while completely ignoring and gaslighting anyone who wasn't 100% on board with what they were doing. Safari argued that there should be a d…

What were these 20 new specs?

After multiple specs had already been pushed through, they finally decided to write down a list of what is still needed.

22 items: https://w3c.github.io/webcomponents-cg/2022.html

In those things like ARIA are not a single spec. It's now close to five different proposals and a huge ARIA Object Model proposal.

Similar thing with Form Associated Controls: it's not one spec. It's a bunch of specs fixing idiotic issues like this: https://github.com/WICG/webcomponents/issues/814

Note: easily half of these only exist because of web components and for web components. Literally nothing else has these issues.

Re: The time is right for a DOM templating API

#227
post #225

Earlier quoted context omitted.

Im not sure what you're referring to, they seem pretty straightforward to me. Create a class that extends HTMLElement, implement stuff in connectedCallback and attributeChangedCallback. Return a list of attributes in static observedAttributes. Or use some extended class if you want, there are plenty and they're easy to create your own.

You mean other than the 20+ web specs they added to platform (often to "fix" problems that they themselves introduced and/or that no one else has)? https://w3c.github.io/webcomponents-cg/2022.html (this list appeared after half a dozen or more specs had already been rammed through) Or that their mere existence infects nearly every spec in existence delaying and needlessly complicating actual useful specs like Scoped…

I don't think it's surprising that a feature like web components would require new specs, isn't that how standard web features work?

Re: The time is right for a DOM templating API

#228
post #226

Earlier quoted context omitted.

What were these 20 new specs?

After multiple specs had already been pushed through, they finally decided to write down a list of what is still needed. 22 items: https://w3c.github.io/webcomponents-cg/2022.html In those things like ARIA are not a single spec. It's now close to five different proposals and a huge ARIA Object Model proposal. Similar thing with Form Associated Controls: it's not one spec. It's a bunch of specs fixing idiotic issues l…

Right but what were these required specs for the existing implementation?

Re: The time is right for a DOM templating API

#229

Earlier quoted context omitted.

Web components were such a big disappointment. 200% the complexity for 20% of the functionality. Everything coming out of that area seems to be hideously over-engineered while failing to solve the problems people wanted them to. My feeling is that they were focused on designing something that is aimed at building form controls, not the kinds of components web developers use in practice. They are designed to make brow…

It should have been possible to declare and use simple web-components - which use a template and a CSS class - without any Javascript.

You can with DSD.

Re: The time is right for a DOM templating API

#230
post #167

DOM templating is just like JavaScript classes. Classes in JavaScript were requested since the earliest of times and always rejected until ES6 (2014), because they are/were: * always unnecessary * always artificial * only vanity * only desired by insecure persons not familiar in the technology * only qualified as bad idea but necessary because people were just going to do it anyways So far the DOM has managed to esca…

It is slightly different. Classes ended up being worse than what they were trying to supplement. Templating, if done right at least (a big if, granted), can bring small improvement. If classes were better, we wouldn't see them the same way now.

How classes could be better? I don't think it's missing something that would make me use it
Post reply on HN