News for hackers. Stuff that matters.
Re:Predicting the next Math.random() in Java by MichaelGG on Monday September 01, 2014 @03:53PM (#8254434)
How did Java and up with such a poor implementation? Certainly these things were known when writing that library?
Re:Predicting the next Math.random() in Java by TheLoneWolfling on Monday September 01, 2014 @05:14PM (#8254721)
Java has a number of... questionable, shall we say, design decisions.

Some of it is legacy cruft - Random was first released in, what, 1995?

Some of it is fallout of it being designed by committee - "we need it to pass this bunch of certifications, which means we have to do this bunch of things even though it doesn't make much sense to do so".

And some of it is undoubtedly the classic execution speed / maintainability tradeoff - no-one has unlimited dev time, Oracle included. A LCRNG is simple and well-known.

Re:Predicting the next Math.random() in Java by ygra on Monday September 01, 2014 @05:27PM (#8254755)
Also they cannot change it now, because its behaviour is documented and people certainly rely on it somewhere.

And it's about km owing what tools to use for what job anyway. I'd you just need to roll a few dice, Random is fine enough. If you need generated passwords, or cryptographic keys, you use SecureRandom. And if you need to run Monte Carlo simulations you'll just implement either MT-19937 or one of the WELL generators.

Re:Predicting the next Math.random() in Java by gleenn on Tuesday September 02, 2014 @04:37AM (#8256383)
I remember reading they pulled the implementation almost straight out of TAOCP, from good old Donald Knuth (if that's enough of a name drop). It might not be great, but at least it was from a reasonably respectable, academic source and not copy-pasta'd out of stackoverflow.