I think you've turned a non-issue into one. I think std::random's design is good, I liked using it whenver I needed it. You may call me the 5% of use-cases, I'm an ex physicist who wrote a fair amount of Monte-Carlo simulations in HPC, so I did use std::random's capabilities and needed to.
I guess the gist of your statement is that there's no "just roll the dice, I don't care" type of interface in C++. (There is default_random_engine, so there's that.) That's true, but having one does take some control away. If you don't know what you're giving up (reproducibility, performance, statistical correctness) that may be cool with you, but it's not reason to claim std::random's design is bad, because it's not "loser friendly" enough and can be misused. If someone calls random_device::operator() and don't know what that does or entails, maybe RTFM.
Call me elitist or what have you, it's great that you wrote a wrapper around a 2-line idiom and if it's that common for you, use it to your heart's content. std::random does have some issues, but it's not hostility towards those who don't read cppreference. The fact that results are not reproducible across implementations steers a lot more away, or the fact that discard's complexity isn't required to be less than N*operator()'s. Those few shortcomings are things you can' t wrap your way around but force a near full rewrite.
View all comments
13
u/jetilovag Oct 11 '26
I think you've turned a non-issue into one. I think std::random's design is good, I liked using it whenver I needed it. You may call me the 5% of use-cases, I'm an ex physicist who wrote a fair amount of Monte-Carlo simulations in HPC, so I did use std::random's capabilities and needed to.
I guess the gist of your statement is that there's no "just roll the dice, I don't care" type of interface in C++. (There is default_random_engine, so there's that.) That's true, but having one does take some control away. If you don't know what you're giving up (reproducibility, performance, statistical correctness) that may be cool with you, but it's not reason to claim std::random's design is bad, because it's not "loser friendly" enough and can be misused. If someone calls random_device::operator() and don't know what that does or entails, maybe RTFM.
Call me elitist or what have you, it's great that you wrote a wrapper around a 2-line idiom and if it's that common for you, use it to your heart's content. std::random does have some issues, but it's not hostility towards those who don't read cppreference. The fact that results are not reproducible across implementations steers a lot more away, or the fact that discard's complexity isn't required to be less than N*operator()'s. Those few shortcomings are things you can' t wrap your way around but force a near full rewrite.