News for hackers. Stuff that matters.
Re:WASM 3.0 Completed by flohofwoe on Wednesday September 17, 2025 @04:07PM (#45280764)
The calls to JS are quite cheap, when trusting the diagrams in here it's about 10 clock cycles on a 2 GHz CPU per call (e.g. 200 million calls per second):

https://hacks.mozilla.org/2018/10/calls-between-javascript-a...

The only thing that might be expensive is translating string data from the language-specific string representation on the WASM heap into the JS string objects expected by the DOM API. But this same problem would need to be solved in a language-portable way for any native WASM-DOM-API, because WASM has no concept of a 'string' and languages have different opinions about what a string looks like in memory.

But even then, the DOM is an inherently slow API starting with the string-heavy API design, the bit of overhead in the JS shim won't suddenly turn the DOM into a lightweight and fast rendering system.

E.g. it's a bit absurd to talk about performance and the DOM in the same sentence IMHO ;)

Re:WASM 3.0 Completed by davexunit on Wednesday September 17, 2025 @04:19PM (#45280900)
Wasm could have had a concept of a string. I frequently mourn the rejection of the imo excellent stringref proposal. https://github.com/WebAssembly/stringref
Re:WASM 3.0 Completed by adzm on Wednesday September 17, 2025 @06:02PM (#45281910)
wasm 3 has the JavaScript string built-in now according to TFA
Re:WASM 3.0 Completed by davexunit on Wednesday September 17, 2025 @08:25PM (#45283273)
That's a different thing. There is still no string type. JS string built-ins are a kludge for web targets only.
Re:WASM 3.0 Completed by titzer on Thursday September 18, 2025 @09:11AM (#45289235)
Just reimplement those JS string builtins in another host environment and provide it as a Wasm library. Stringref was basically just proposing pushing JS strings down into Wasm, which many in the CG saw as a big chunk of one specific platform just moving down a layer, into the engine.
Re:WASM 3.0 Completed by davexunit on Thursday September 18, 2025 @06:01PM (#45295550)
Having used and implemented stringref and having seen the built-ins proposal I really think stringref is a much better developer experience and the CG is wrong. The built-ins are better than nothing but it's a terrible hack.
Re:WASM 3.0 Completed by dcchambers on Wednesday September 17, 2025 @04:12PM (#45280814)
Fair enough, thanks for sharing!
Re:WASM 3.0 Completed by sjrd on Wednesday September 17, 2025 @05:07PM (#45281408)
If your language and its compiler use JS String Builtins (part of Wasm 3.0) for their strings, then there is no cost to give them to JS and the DOM.