Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was going to reply "but SharedArrayBuffer!" until I checked the site below and came back to reality.

https://caniuse.com/#feat=sharedarraybuffer



Funny 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-sharedarraybuffer...


And 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.


Although 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.


I 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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: