5 ms·
This kind of stuff seems scary to me. One JavaScript engine decides to use this algorithm, another that. This type of change could lead to higher potential of b
by cdnsteve 11y ago
This kind of stuff seems scary to me. One JavaScript engine decides to use this algorithm, another that. This type of change could lead to higher potential of bugs and unexpected behaviour, the average developer just can't figure out when say, using Firefox or Chrome for testing.
When algorithms are getting tinkered with behind the scenes, this leads me to believe there's still way too much churn in the JS space.
- spicyj 11y agoOSes don't guarantee exactly how rand() behaves, do they?
- masklinn 11y agorand(3) isn't really the OS's concern, it's part of POSIX and the C standard which don't indeed, but could. Java specifies exactly how java.util.Random should be implemented (LCG from TAOCP with a 48 bit seed), which on the one hand means its well-understood and stable across machines, and on the other hand means it's kinda crap and can't ever be upgraded.
- mmalone 11y agoYep and with the new SplittableRandom they seem to have opted for a more subjective definition with a guaranteed minimum cycle length and passing marks on Diehard. Seems like a happy middle ground.
- geofft 11y agoIt's a random-number generator. It's not supposed to have expected behavior.
- TheOtherHobbes 11y agoIf it's a seedable generator, it certainly is. There are applications in creative coding and gaming where it's critical to have a reproducible random sequence that gives the same results on all platforms.
- jjuhl 11y agoBut Math.random() never promised to be that (reproducible that is). So changing the underlying algorithm is just fine.
- dchest 11y agoIt's is not seedable.
- alanh 11y ago> reproducible random sequence That’s a hell of an oxymoron. Edit Yes, I know obviously the intent was to refer to a pseudorandom sequence, but that’s not what was said. It’s also not what Math.random promises. It promises random-seeming output, nothing more, nothing less. It did not promise a cross-platform, reliably reproducible stream of pseudorandom numbers, and it would be in error to abuse a black-box "random" API by considering it to be a fully specified pseudorandom stream.
- dchest 11y agohttps://en.wikipedia.org/wiki/Pseudorandom_number_generator https://en.wikipedia.org/wiki/Pseudorandom_number_generator