Hacker News new | ask | show | jobs
by mark_edward 2933 days ago
Web Components?
1 comments

No, because web components assume you're using the DOM. Which we definitely do not want. I want to go lower level. Give me a hashmap of nodes currently on screen. Let me design how the nodes are arranged in a render tree. Let me design how the nodes are redrawn. Let me design how the nodes are styled. I shouldn't have to compile my styles to CSS. Make the browser a rendering slave with a small but effective layout engine + UI API.
What about accessibility? Accessibility helpers would need semantic information about the UI to be of any use. And I doubt that many homegrown or halfbaked Ui libraries (which would certainly sprout like mushrooms on a platform like yours) would provide correct annotations through an accessibility API. Most developers wouldn't care.
Accessibility is definitely something I have thought about, too. Including accessibility features in the API is vital I think. I'm not very familiar with accessibility features as they exist today, but I think it would be possible for longer term projects built on top of such a UI system to emerge which would provide accessibility information by default, and the rest would resemble what we have with HTML today.
Can't you do this by yourself by implementing a thin layer on top of the canvas element? What do you need more than a z-map of all of your nodes to keep track of which one is at the top and should receive mouse and touch events?
A render list would be more efficient than a tree, simply because you're not jumping left and right in RAM with cache misses on every jump.

A hashmap of nodes on screen is still very high level; you're basically replacing the DOM with data, yet keeping the exact same structure. But now you lose static types and everything is slower.

Redrawing doesn't happen at the node level either; that would be terribly inefficient. Things are instead batched together.

You don't have to compile your styles to CSS currently; just write them as JS objects and call the CSS constructors yourself from code. You'll quickly find its not productive for most styling.

I simply don't believe the vast majority of developers to be able to properly handle rendering at that level. No offence but all your points about low-level rendering is not how it actually works. Its incredibly easy to fool yourself into thinking you wrote a well-designed, efficient piece of code and learn years later every single piece of it was far from optimal.

Thats why we have layers of abstractions.