4 ms·
I was going to reply "but SharedArrayBuffer!" until I checked the site below and came back to reality. https://caniuse.com/#feat=sharedarraybuffer https://cani
by disease 7y ago
I was going to reply "but SharedArrayBuffer!" until I checked the site below and came back to reality.
https://caniuse.com/#feat=sharedarraybuffer https://caniuse.com/#feat=sharedarraybuffer
- pietrovismara 7y agoAnd as I said, SharedArrayBuffer is a fixed length, number only array. While it may work well for some use cases, it really can't for many others. Or am I missing something? By the way, browser compatibility is not a concern if you develop for Electron. Just target Chrome and you're done.
- meheleventyone 7y agoI think they meant it’s not supported. Although saying that memory in lower level languages is basically treated as an array of numbers and you can treat the array buffers similarly. It’s also how Wasm memory is exposed. So you can serialize JS and other data in and out of them.
- seangrogg 7y agoAlthough it's number-only said numbers can be used to represent anything, really. If you can convert your data to number-friendly formats and back there's really no issue. If you need strings you can use the native TextEncoder/TextDecoder and shuffle things around as UTF-8. If you need JSON-like objects you can look at encoding formats such as Protocol Buffers, Thrift, and the like. This introduces non-zero latency shuffling data between formats but that's largely what normally occurs over IO boundaries anyways.
- littlecranky67 7y agoFunny thing is, it is not supported on purpose. Most browser had support for SharedArrayBuffer but it got disabled when Meltdown/Spectre came to light (as well as high precision timers in the browser) [0]. [0]: https://www.sitepen.com/blog/the-return-of-sharedarraybuffers-and-atomics/ https://www.sitepen.com/blog/the-return-of-sharedarraybuffer...