My problems with JS:

1. Allocating objects or closures results in death by garbage collection.
2. So I spend tons of effort managing indices, juggling reused objects, and passing them around awkwardly because functions can only return 1 value.
3. As for the objects, only TypedArrays/ArrayBuffers are fast, but they too require juggling due to having fixed maximum lengths.

If I started using Rust or something instead, would it ease these specific problems? Or is this just my life now?

@jonikorpi my life now as well. 😌

My assumption would be similar problems, but better tooling, in Rust (etc) …but I haven’t worked a lot with these languages either.

Maybe there are coding patterns and/or tooling that would help in JS? I’ve been finding the flyweight pattern helpful — some CPU overhead but not the memory/GC issues. Recent example:

https://github.com/CesiumGS/cesium/pull/13212

BufferPrimitiveCollection: Add point/line/polygon data models by donmccurdy · Pull Request #13212 · CesiumGS/cesium

Description Highlights Adds performance- and memory-oriented APIs for working efficiently with large vector collections: BufferPrimitive BufferPoint BufferPolyline BufferPolygon BufferPrimitive...

GitHub
@donmccurdy I guess ECS is the most popular bigger pattern? I’m curious about it, but unsure how to apply it properly outside very simulation-oriented use cases.