Live data from Hacker News

The C++ community is polarized about C++11's random-number facility

pcg-random.org

21–30 of 67 posts

Re: The C++ community is polarized about C++11's random-number facility

#21
post #5

Features like this make me think that C++ is designed by people who think that perfection is reached when there is nothing more to add. As a C developer, I side with Antoine de Saint Exupéry.

I think this is a natural consequence of low-level APIs. Anything deemed worthy of being configured by caller is made into an extensible interface, whether that be through flag arguments or types. Unless some lib is very opinionated on how things should be done, the extension/customization hooks have to exist in one form or another.

To satisfy the two camps though (low level control vs "give me some sane default or package up common combinations") someone just writes the higher level API on top.

Re: The C++ community is polarized about C++11's random-number facility

#23
post #2

I do not like it because http://stackoverflow.com/questions/18880654/why-do-i-get-sam...

Because Microsoft implemented random_device correctly while MingW / GCC hasn't? Its a bug in MingW. Which isn't a big deal because Microsoft Visual Studio Community Edition is an excellent IDE and compatible with OSS projects now.

Could you point to the gcc bug? Note: the standard does not require a non-deterministic random_device, at least C++11 doesn't, so the behaviour as described in the stackoverflow link would be allowed.

Re: The C++ community is polarized about C++11's random-number facility

#24
post #8
post #5

Features like this make me think that C++ is designed by people who think that perfection is reached when there is nothing more to add. As a C developer, I side with Antoine de Saint Exupéry.

Sigh... Too often that criticism is leveled at C++ without an understanding of the terrain. I don't think C developers should be sitting on a high horse on this one. C represents a pretty good example of the problem. Almost every program that relies upon the standard C runtime's random functions has a flawed random distribution, so any correct program completely bypasses that infrastructure and/or has a ton of additi…

> That open source

Man, autocorrect killed me there. That should be "That open sore".

Re: The C++ community is polarized about C++11's random-number facility

#25
post #21
post #5

Features like this make me think that C++ is designed by people who think that perfection is reached when there is nothing more to add. As a C developer, I side with Antoine de Saint Exupéry.

I think this is a natural consequence of low-level APIs. Anything deemed worthy of being configured by caller is made into an extensible interface, whether that be through flag arguments or types. Unless some lib is very opinionated on how things should be done, the extension/customization hooks have to exist in one form or another. To satisfy the two camps though (low level control vs "give me some sane default or p…

It is entirely possible to write a highly configurable interface with sane defaults. Indeed, the proposal in this article goes a long way in that direction.

Re: The C++ community is polarized about C++11's random-number facility

#26

"To the extent that anyone cares about C++11's random-number facility at all, the C++ community is polarized between two views—one that likes it, and one that hates it." Isn't that almost a tautology? "People who care about X either love it or hate it".

There's a wide spectrum between love and hate.

Yeah, and all those people probably aren't participating in online discussions about it. I'm pretty happy with most aspects of , but I don't seek out arguments. I just use it.

Re: The C++ community is polarized about C++11's random-number facility

#27
post #25
post #21

Earlier quoted context omitted.

I think this is a natural consequence of low-level APIs. Anything deemed worthy of being configured by caller is made into an extensible interface, whether that be through flag arguments or types. Unless some lib is very opinionated on how things should be done, the extension/customization hooks have to exist in one form or another. To satisfy the two camps though (low level control vs "give me some sane default or p…

It is entirely possible to write a highly configurable interface with sane defaults. Indeed, the proposal in this article goes a long way in that direction.

Sometimes the right defaults depend on context unavailable to the low level library author. But irrespective of who provides the higher level API, the bottom line is that there needs to be an API that's most flexible when the flexibility is warranted. This is really in reference to Colin's "nothing more to add" remark.

Re: The C++ community is polarized about C++11's random-number facility

#28
post #12
post #7

I like this proposal and I agree that randint is a bad idea.

I think there is a case to be made for doing both. The one advantage of randint is that it makes for a convenient migration path for those relying on std::rand() and friends. I honestly am a bit at a loss though in terms of understanding how this proposal makes things significantly easier for programmers. Absent this proposal, you would write: std::default_random_engine e(std::random_device{}); std::uniform_int_distr…

[deleted]

Re: The C++ community is polarized about C++11's random-number facility

#29
post #12
post #7

I like this proposal and I agree that randint is a bad idea.

I think there is a case to be made for doing both. The one advantage of randint is that it makes for a convenient migration path for those relying on std::rand() and friends. I honestly am a bit at a loss though in terms of understanding how this proposal makes things significantly easier for programmers. Absent this proposal, you would write: std::default_random_engine e(std::random_device{}); std::uniform_int_distr…

The current way separates out what will be gotten back from the engine from the actual invocation. In comparison, the proposal lets me look at one line and know what will be returned:

    rng.uniform(1,17)
I know exactly what to expect. Compare that to:

    uniform_dist(e);
Unless the variable is named very well ("UniformDistOneToSix"?), I don't know what that line does.

Not to mention, what if I want to roll a bunch of numbers in a row? Do I create all the different distributions that I may ever need ahead of time? If I don't know what all random ranges I'll need, I guess I can just create them on the stack as needed, instantiating objects willy nilly. Eew.

Re: The C++ community is polarized about C++11's random-number facility

#30
post #26

Earlier quoted context omitted.

There's a wide spectrum between love and hate.

Yeah, and all those people probably aren't participating in online discussions about it. I'm pretty happy with most aspects of , but I don't seek out arguments. I just use it.

This is basically the problem with the whole Internet though ;)
Post reply on HN