Show HN: Simulating 20M Particles in JavaScript (opens in a new tab)dgerrells.com
561 pointsHad some fun with shared array buffers over many months of free time.
Skip to the end to play around with the final app.
Open to ideas on how to simulate more whilst staying in js land.

Comments (70) 25 threads
Earlier commentsToo bad we cant just rely on JS only and have to involve a bunch of DOM operations, which is usually the slow part of the UIs we create.
No? With WebGL and soon WebGPU, or in this case here with writing to a imagebuffer and just passing that to canvas, you don't have to use the DOM anymore since quite a while.
(but then you don't get all the nice things html offers, like displaying and styling text etc)
In reality, you're right, there are alternatives, but for the basic web documents, it kind of hurts more than help to use them.
However, that's not where the problem starts. A lot of web sites are slow because they simply run too much code that doesn't need running in the first place and allocates objects that don't need to be allocated.
We don't need lower level constructs if we can simply start by removing cruft and be more wary of adding it. Go back to KISS/YAGNI.
My custom engine is built on a very similar solution using SharedArrayBuffers but there are still many things in this article that I'm eager to try, so thanks!
Not sure I understand. The flicker is not due to sometimes the screen drawn with white(like I assumed) and just because of my mobiles light settings?
Other simulations similar to this, don't have this flicker on my devive.
(still impressive work, genuine question to avoid this effect in my experiements)
And no matter the technical reasons, for some people this might be a serious health issue, so a warming might make sense in the current state.
All comments shown.
Couldn't load more comments. Check your connection and try again.