News for hackers. Stuff that matters.
Re:Tools we used to create a hit HTML5 game on Steam by pietrovismara on Tuesday November 19, 2019 @01:15PM (#21576177)
If only JS had better multithreading shared memory capabilities it would be perfect for me. But just with fixed length array buffers limited to numbers I can't do much. I tried regular IPC instead but there's too much latency. It is a huge shame.
Re:Tools we used to create a hit HTML5 game on Steam by BubRoss on Tuesday November 19, 2019 @03:04PM (#21577647)
When you say regular IPC, have you tried this?

https://github.com/LiveAsynchronousVisualizedArchitecture/si...

It should be MUCH faster than loopback IP IPC if that's what you were trying.

Re:Tools we used to create a hit HTML5 game on Steam by disease on Tuesday November 19, 2019 @01:51PM (#21576710)
I was going to reply "but SharedArrayBuffer!" until I checked the site below and came back to reality.

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

Re:Tools we used to create a hit HTML5 game on Steam by littlecranky67 on Tuesday November 19, 2019 @04:24PM (#21578472)
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...

Re:Tools we used to create a hit HTML5 game on Steam by pietrovismara on Tuesday November 19, 2019 @02:40PM (#21577330)
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.

Re:Tools we used to create a hit HTML5 game on Steam by seangrogg on Tuesday November 19, 2019 @03:15PM (#21577771)
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.

Re:Tools we used to create a hit HTML5 game on Steam by meheleventyone on Tuesday November 19, 2019 @03:13PM (#21577755)
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.