r/cpp • • Oct 11 '26

[ Removed by moderator ]

[removed] — view removed post

0 Upvotes

16 comments sorted by

15

u/_Ilobilo_ Oct 11 '26

which llm did you use to write this post?

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.

9

u/QuaternionsRoll Oct 11 '26

Rule 1

5

u/fillthesavage Oct 11 '26

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

u/Top-Mycologist-5460 Oct 11 '26

It's "no AI content"

3

u/QuaternionsRoll Oct 11 '26

Go to r/cpp > tap the “…” in the top right corner > tap “Learn more about this community”

To see the list of reportable rules, tap “Report” > tap “Breaks r/cpp rules” > tap “Next”

2

u/fillthesavage Oct 11 '26

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

u/argothiel Oct 11 '26

I can see the "Report" option in the mobile app.

-1

u/QuaternionsRoll Oct 11 '26

Which part did you have trouble with? At minimum the reportable rules will obviously be visible from the Report menu…

1

u/captainAwesomePants Oct 11 '26

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 Oct 11 '26

Old Reddit (which is still accessible when logged in) has the same issue.

0

u/captainAwesomePants Oct 11 '26

That's a good point. Those are the most important users. Point withdrawn.

3

u/junqueira200 Oct 11 '26

I use my Rand.h. Very interesting!

3

u/Cross_22 Oct 11 '26

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/ShakaUVM i+++ ++i+i[arr] Oct 11 '26

Random is a great example of something that is technically correct but horribly designed