News for hackers. Stuff that matters.
Re:Why I Write Games in C (yes, C) by RobertKerans on Saturday September 21, 2019 @06:32PM (#21038302)
You wouldn't have this still up somewhere like GH would you? I'm currently writing a toy ECS implementation and have somewhat similar needs, and I've been trying to build up a reference library of sorts covering novel ways of dealing with these kind of JS issues
Re:Why I Write Games in C (yes, C) by tomxor on Saturday September 21, 2019 @07:32PM (#21038595)
No sorry, this is from more than 5 years ago and it was never FOSS, but I only implemented rudimentary operators anyway, you could easily adapt existing libraries or write your own, the above concept is more valuable than any specific implementation details... the core concept being, never implicitly generate objects, e.g operate directly on parameter objects, or re-use them for return value, or return persistent internal objects (potentially dangerously since they will continue to be referenced and used internally).

All of these ideas require more care when using the library though.

Re:Why I Write Games in C (yes, C) by RobertKerans on Sunday September 22, 2019 @06:57PM (#21044521)
Thank you though, what you've written here is very useful -- you're describing things I'm immediately recognising in what I'm doing. As I say, it's just a small toy (and I think one that would definitely be easier in a different language, but anyway...). At the minute I'm actually at the point where I'm preallocating and persisting a set of internal objects, and at a very very small scale it's ok, but each exploration in structure starts to become manageable pretty quickly.
Re:Why I Write Games in C (yes, C) by meheleventyone on Sunday September 22, 2019 @09:09AM (#21041184)
Three.js implements their math this way.

https://github.com/mrdoob/three.js/blob/master/src/math/Vect...

You can see most operations act on the Vector and there are some shared temporary variables that have been preallocated. If you look through some of the other parts you can see closures used to capture pre-allocated temporaries per function as well.

Re:Why I Write Games in C (yes, C) by RobertKerans on Sunday September 22, 2019 @06:50PM (#21044492)
Ah brilliant, that's definitely useful. Thank you for the pointer