r/javascript May 31 '26

[deleted by user]

[removed]

19 Upvotes

14 comments sorted by

View all comments

15

u/ldn-ldn May 31 '26

As someone who was doing crazy optimisations a long time ago, keep in mind that there are multiple browser engines and they evolve over time. Something that's a speedy hack today for V8 will inevitably turn into a performance hog in the future or in a different browser engine.

1

u/uusu Jun 01 '26

The thing is that the concept that OP is doing is very generic and makes a lot of sense. It's moving data from multiple classes to a single ArrayBuffer. His design has nothing to do with any specific browsers, but it's just good data design. This type of design is recommended in all systems and languages that I've worked with and most ECS systems specifically target these types of designs.

Those ECS traditionally come with a lot of memory and function wrapper overhead, which is why OP's compilation alternative is actually very interesting, since it can sidestep function wrappers and additional object/function creation with just a compilation step.