3 ms·
IBM is probably the last place I expect to find a game dev tutorial Are they trying to mimic Digital Ocean's docs to promote their brand?
by trinovantes 4y ago
IBM is probably the last place I expect to find a game dev tutorial
Are they trying to mimic Digital Ocean's docs to promote their brand?
- scaglio 4y ago> IBM is probably the last place I expect to find a game dev tutorial Exactly my thought. Totally unexpected.
- samwillis 4y ago> Updated 19 November 2012 | Published 20 November 2012 Not only is this an old post published just after DO lunched - but it apparently was updated before it was published… Anyone who was new to JS in the last five years is going to see the older syntax in this post and be like “what ‘prototype’? Why aren’t they using ‘let’ and ‘const’? Why aren’t they using forEach to loop through that array? Why isn’t this in TypeScript?”…
- Kiro 4y agoMaybe it's not true anymore but forEach used to be much slower, which matters when you make a game engine and need to iterate lists at least 60 times a second.
- mvladic 4y agoWhy would they use forEach? Is that criteria that your code is more modern? Or by forEach you mean: "for (const entity of entities) {...}"?
- samwillis 4y agoforEach landed in Chrome in 2014 after this post, at the same time as for...of. True that forEach was available in some browsers earlier than that and could be polyfilled. Which do I mean? either.
- jsgamedevthrow 4y agoI have no idea what its like these days, but back then a ton of those sorts of methods would cause extra allocations (and thus unnecessary GC). That is the very last thing you want in a game engine.
- fein 4y agoYou are correct. Everything that isn't a native for loop (forEach, map, reduce, etc) is slower than a native for loop. https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/ https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_...
- dahart 4y agoLooks like it’s gotten better recently with ratios like 1.5x - 3x; it wasn’t that long ago that using the functional iterators was 10x slower than imperative loops. Still, I have a hard time choosing the functional iterators even the cases that are only 50% slower, and even though I prefer them for how clean and elegant it makes the code. Performance and energy use matters, especially in a physics engine. Defaulting to the slower style might not be visible initially, but is sapping cycles from every corner of the code.
- pharmakom 4y agoforEach mixes statements and expressions so (imho) is poor style.