▲ | dfabulich 7 days ago | ||||||||||||||||
Browser vendors can't simply "choose" to open direct DOM access to WASM. When defining standardized DOM APIs in WebIDL, WebIDL assumes that you can use JavaScript strings, JavaScript objects + properties, JavaScript Exceptions, JavaScript Promises, JavaScript garbage collection, and on and on and on. Almost all of the specification of WebIDL itself is about the dozens of types that it assumes the platform already provides. https://webidl.spec.whatwg.org/ WebAssembly doesn’t have any of those things. As a low-level VM, it supports only modules, functions, bytes, numbers (32-bit and 64-bit integers and floats), arrays (called “tables”), and opaque pointers (“reference types”). No one has ever standardized a DOM API for low-level languages. You’d presumably need to start by defining a new low-level WebIDL design language just to define a low-level DOM API. Defining WebIDL itself has taken decades. Today, the browser vendors aren’t convinced that a new low-level DOM API is worth their time. It’s better to make existing JS web apps faster than it is to begin a multi-year (multi-decade?) project to make a new thing possible that could be better in the long run. | |||||||||||||||||
▲ | jauntywundrkind a day ago | parent | next [-] | ||||||||||||||||
There is a JS strings spec for wasm underway. https://github.com/WebAssembly/js-string-builtins This feels so much like one of those cases where perfect is the enemy of the good. Node.js spent a decade being wrapped about the axle, convinced that cjs and esm could never work together. Ignoring that it worked great in standard-things/esm. But eventually Bun came around and that somehow made the case that all the hemming & hawing was nonsense all along, that doing nothing was worse than letting Fear Uncertainty and Doubt reign. It just seems so unlikely that much of JS really matters for webidl. WebIDL specifies mostly structures and routes. It throws some exceptions but that doesn't seem particularly incompatible with wasm. WebIDL has promises, which is already pretty well solved by https://github.com/WebAssembly/js-string-builtins (which alas only Chrome seems to be moving on). GC is also in wasm now. I just don't get the defeatism. Fear Uncertainty and Doubt can be so seductive, anti-belief can be so fierce, and it sucks when things aren't perfect or when there's warts, but the paralysis here & anti-will seems so wildly disproportionately strong. | |||||||||||||||||
▲ | lenkite 7 days ago | parent | prev [-] | ||||||||||||||||
There is the Web Assembly Component Model. Nothing is really preventing browser vendors from exposing a WASM host interface to DOM, exposing it as a Component Model interface. This would allow DOM functions to be invoked from WASM without hand-written/generated JS glue code. Nobody is really calling for exposing the full-suite of WebAPI's. But basic DOM access allowing manipulation of page elements would be immediately leveraged by all the WASM-UI frameworks available today. Framework authors would throw out all the generated JS glue code which adds painful overhead pronto with great joy. | |||||||||||||||||
|