Java's random number API is a bit muddied, but thanks to JEP 356 it will be more usable, extensible, and robust in #Java17. Let's see what changed! 🧵 (For the long version: nipafx.dev/java-random-ge… ) 1/7
What do I mean by "muddied"? Right now, we have four classes (and no interface), one of them unrelated to the other three, with inconsistent APIs (why no `Random.nextLong(long bound)`? 🧐). Implementation isn't great either, e.g. identical pieces code in different classes. 2/7
JEP 356 (openjdk.java.net/jeps/356) introduces a new type hierarchy with `RandomGenerator` at the top that unifies the API and is implemented by all existing classes. New helper classes (github.com/openjdk/jdk/bl…) make implementations easier and less repetitive. 3/7