3 ms·
I've poked around in Chrome's source code, and what struck me is that the JS-to-C++ interface seems pretty similar to what's going on in a game engine - C++ cla
by torginus 5y ago
I've poked around in Chrome's source code, and what struck me is that the JS-to-C++ interface seems pretty similar to what's going on in a game engine - C++ classes with generally pretty similar APIs to their JS counterparts are wrapped and exposed to JavaScript - I think this is the way WebAssembly should be implemented as well- an interface that replaces this interaction layer with its own - since the native objects' lifetimes are handled by C++, a typical WASM target language (say C++ or Rust) would be pretty straightforward, since it could access these resources with similar semantics.
Additonally, in managed, garbage collected runtimes, like .NET, the handling of native resources with explicit lifetimes is a solved problem as well - garbage collection would be handled by the languages own runtimes, no need to move this responsibility to WASM.
This would also avoid the issue of having the .NET GC and the JS GC coexist - this typical too many cooks scenario of 2 separate GCs is a nightmare to manage.
Another daring, pie-in-the-sky thought: Javascript could use this interface as well, becoming just one of the many languages that can target the browser.