Hacker News new | ask | show | jobs
by cmpolis 2400 days ago
This is one of the goals of Polymer- a cleaner API/abstraction layer on top of web components, right?
2 comments

Well, forget about "Polymer the library", it served us well but it's very legacy at this point. The successor is https://lit-element.polymer-project.org and it's awesome.
Why on earth do you need something that heavy? How about this 200-line lib instead: https://github.com/wisercoder/uibuilder It lets you TSX format (same to React) to implement as well as to use web components.
> Unlike React.js UIBuilder does not do incremental screen updates

LitElement + lit-html give you very efficient updates, and don't require non-standard JS like JSX.

lit-html is no more of a standard than JSX. In fact JSX is better because tools like VSCode is able to validate both HTML and embedded JavaScript.
Huh? lit-html uses standard JavaScript. That's it. JSX is a non-standard extension. So yes it is more standard than a non-standard, and lit-html runs directly in browsers without any transpilation while JSX very much doesn't.

VS Code is as able to analyze lit-html templates as well as JSX via the lit-plugin extensions. It gives you type-checking, code completion, hover-over docs, and linting.

lit-html needs a 1600 line library where as UIBuilder is a 200-line library: https://github.com/wisercoder/uibuilder/blob/master/UIBuilde...

Yes, JSX needs transpilation but that happens at compile-time. Which is better, pre-processing at compile-time, or "transpilation" (i.e., string processing) at run-time?

OK, so plugins can enhance code editing. But what about compile-time checks? With TSX, if you have a mis-matched tag the TypeScript compiler will give you an error.
So we finally got a goddamn proper standard and we're already cheering for the next API to throw in front of it to make it "cleaner"?
Actually, no. There's no need or possibility to make it "cleaner", but there's always the direction of making it more "high level". These are very different things.

If you look at https://lit-element.polymer-project.org — it's just a base class that integrates declarative DOM templates.

The platform APIs are not opinionated about templating, they just provide proper mechanisms for declaring elements and having isolated DOM subtrees. It makes sense to leave templating to libraries, because… well, good luck on getting even just two people to agree about how templating should be done :)