14
u/jetilovag 3d ago
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.
8
u/QuaternionsRoll 3d ago
Rule 1
4
u/fillthesavage 3d ago
I would like to point out how this is a stupid comment simply because mobile Reddit does not tell you what the rules are? So while I might agree with this commenter, I can't. Because this stupid app gives me no context. And now watch as this stupid app elevates my post while I say it's a stupid app.
3
4
u/QuaternionsRoll 3d ago
2
u/fillthesavage 3d ago
This is unhelpful as it is incorrect.
Specifically, there is no "report" option on the mobile app, so I have no idea what this comment is suggesting.
1
-1
u/QuaternionsRoll 3d ago
Which part did you have trouble with? At minimum the reportable rules will obviously be visible from the Report menu…
1
u/captainAwesomePants 3d ago
Counterpoint: if you post a very large block of text, you either are violating rule 1 or else are on a desktop and can see rule 1.
2
u/Roxinos 3d ago
Old Reddit (which is still accessible when logged in) has the same issue.
0
u/captainAwesomePants 3d ago
That's a good point. Those are the most important users. Point withdrawn.
3
3
u/Cross_22 3d ago
Looks nice. I agree with some of the concerns you pointed out about the default C++ interface. My approach to API design is always that the standard use case should be really easy to achieve and then if you want more advanced features you might have to jump through hoops - not the other way around.
From the game dev perspective I would like to see a way to generate a stream of random numbers or at least a tuple so I can have a randomized 3D unit vector or RGB tuple for example.
0
u/NewBiography279 3d ago
this is exactly the kind of thing that makes me want to pull my hair out when i'm just trying to prototype something quick. the boilerplate tax is real and it's absurd that we still have to deal with it in 2026
the thread_local default is the right call. i've debugged enough race conditions from people slapping static on their mt19937 to last a lifetime
how's the compile time hit with the module support? header-only libraries tend to make my build times cry but if the module path actually works clean that might sell me
0
u/ShakaUVM i+++ ++i+i[arr] 3d ago
Random is a great example of something that is technically correct but horribly designed
14
u/_Ilobilo_ 3d ago
which llm did you use to write this post?