4 ms·
> Web Assembly should be a lot faster here, because (depending on implementation) you get denser data structures, better cache locality, no garbage collection,
by oever 9y ago
> Web Assembly should be a lot faster here, because (depending on implementation) you get denser data structures, better cache locality, no garbage collection, and so on.
You can get these advantages by using plain javascript with typed arrays.
https://github.com/vandenoever/baredom https://github.com/vandenoever/baredom
- DonHopkins 9y agoI would guess a lot of the overhead would be thunking back and forth between webasm and js functions, so if you implemented the update in pure js where it can call directly into the DOM apis, and also read pointers, numbers and strings directly out of the webasm data array, then you could avoid any thunking between the two different worlds in the inner loop. By thunking I mean doing this from C++ code: EM_ASM_({ window['asmDomHelpers']['domApi']['appendChild']($0, $1); }, vnode->elm, createElm(vnode->children[i]));
- oever 9y agoSo you propose to interface between C++ and JavaScript via a shared buffer and to eschew any explicit FFI calls. If the data structure is lockless, that is doable.