[ 
https://issues.apache.org/jira/browse/RNG-19?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16920076#comment-16920076
 ] 

Gilles commented on RNG-19:
---------------------------

{quote}{{Wrapper}} [vs] {{Adaptor}}
{quote}
I have the impression that the former is a somewhat clearer (wrt the direction 
of adaptation).
{quote}factory class [...] for conversions
{quote}
The conversion cannot be seamless (a.o. due the different approaches of 
restoring state); my impression is that only the application developer is able 
to decide which API can be missing (e.g. {{setSeed}}) without breaking his 
application. Otherwise, I fear that we embark on a mission to support all the 
issues with 
[{{java.util.Random}}|http://commons.apache.org/proper/commons-rng/userguide/why_not_java_random.html]
 which I wished to avoid in the first place in "Commons RNG".
{quote}{{Collections.shuffle(List<?>, Random)}}
{quote}
The JDK methods can be called directly using an instance of 
[{{JDKRandomBridge}}|http://commons.apache.org/proper/commons-rng/commons-rng-simple/javadocs/api-1.0/org/apache/commons/rng/simple/JDKRandomBridge.html]
 (here the issues evoked above are sidelined because the source of randomness 
is encapsulated in the instance, so that the behaviour of {{Random}} can be 
completely emulated).
 Note that the issue is on the JDK's side (by {{Random}} not being an 
interface) and IMO we shouldn't try to make it look that back-and-forth 
conversion is transparent when it's likely to cause trouble.
{quote}Without adding the commons-sampling dependency for ListSampler::shuffle
{quote}
On the contrary, better to make it clear that {{ListSampler.shuffle}} is to be 
preferred over {{Collections.shuffle}}. :)
{quote}3rd party libraries would likely use Random as the common API.
{quote}
IMHO, we should not promote usage of {{Random}} in any way.

[Quoting|https://bugs.openjdk.java.net/browse/JDK-8154225] a JDK developer:
 "There are many things about the design of Random and its subclasses that we 
regret, but it's too late to fix them now. It's always possible for third 
parties to provide their own PRNG classes."

So, that's what we do.

> System generator (/dev/random)
> ------------------------------
>
>                 Key: RNG-19
>                 URL: https://issues.apache.org/jira/browse/RNG-19
>             Project: Commons RNG
>          Issue Type: Wish
>            Reporter: Emmanuel Bourg
>            Priority: Minor
>
> Commons RNG could include a random number generator based on the output of 
> /dev/random or /dev/urandom on Unix systems.
> Commons Crypto has an implementation that could be used as a starting point:
> https://github.com/apache/commons-crypto/blob/master/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to