std.random suggestions
Dmitry Olshansky
dmitry.olsh at gmail.com
Wed Sep 17 09:00:44 UTC 2025
On Tuesday, 16 September 2025 at 12:04:20 UTC, Denis Feklushkin
wrote:
> I don't like the way the module std.random is designed
>
> From a software side we have three types of ~random numbers
> sources:
> That's all, and nothing superfluous! I.e., if you do not use
> something, it does not creates any global variables, etc. From
> the point of view of the user, seems, everything is also simple
> and clear. It will be difficult to make a issue with RNG in
> this case.
>
> Perhaps this is suitable for Phobos 3?
To be honest this seems like a major overengineering. It’s a
given in a whole lot of languages that random means PRNG with
optional seed. The seed could be obtained via some function to be
largely unpredictable, with the benefit that you could replay the
program with a particular seed to ease debugging / fuzzing etc.
Now of hardware sources most language would provide CryptoRandom
which takes the bits from whatever deemed as secure source of
random bits, most likely get_random or /dev/urandom (yes it is
fine for generating keys, check the literature). Everything else
is plain overengineering and deserves to be written in 3rd party
library by these willing to pursue it.
More information about the Digitalmars-d
mailing list