logoalt Hacker News

dcchambersyesterday at 7:59 PM1 replyview on HN

While technically possible - the calls to javascript slow things down and you're never going to get the performance of just writing javascript in the first place, much less the performance of skipping javascript altogether.


Replies

flohofwoeyesterday at 8:07 PM

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 ;)

show 3 replies