3 ms·
3D renderers have existed in JS for ages so that seems more like a failure of imagination on your part. The nice thing about fixed layout structs is that it le
by meheleventyone 2y ago
3D renderers have existed in JS for ages so that seems more like a failure of imagination on your part.
The nice thing about fixed layout structs is that it leans in to optimizations people are already doing based on the behavior of JS engines where 'shapes' of objects are important and properties can be looked up by offset if you keep your code monomorphic. It can be a bit of a headache to enforce this and you can accidentally fall off a performance cliff if you end up with many 'shapes' for the same thing. By making this a language feature it codifies and blesses what was essentially a hack relying on the implementation of the underlying engine that could change at any time.
There are also TypedArray's that do provide a bunch of cache friendly (but slightly unergonomic) ways to organize data.
A good resource for the sorts of things people are doing to write high-performance JS is here: https://romgrk.com/posts/optimizing-javascript https://romgrk.com/posts/optimizing-javascript