Re:Show HN: I taught my little brother JS, and he made this ...
by fenomas on Thursday January 10, 2019 @06:56AM
(#18873222)
> Also never use Math.pow for squaring numbers (used in the distance function) because it is significantly slower...
Modern JS engines optimize hot functions at runtime - advice like this won't affect actual performance.
Re:Show HN: I taught my little brother JS, and he made this ...
by ghusbands on Thursday January 10, 2019 @09:47AM
(#18874170)
This advice is incorrect. Experimenting in the console in both Firefox and Chrome shows that there's not a significant speed difference between the two, even if you make sure you only call a given function with integers <10000.
Re:Show HN: I taught my little brother JS, and he made this ...
by tim1994 on Thursday January 10, 2019 @10:47AM
(#18874654)
On my laptop it is about 30% slower (tested with Firefox 64).
However I agree, this was not very good advice for someone who just started programming with JS...
Re:Show HN: I taught my little brother JS, and he made this ...
by therein on Thursday January 10, 2019 @06:12AM
(#18873037)
Definitely great job. Reminds me of when I taught my physicist friend C and he wrote a raytracer and a game to demo it the next day. I had never witnessed so many trig functions used on a global context.
Still a very good job for just a week of coding though.