Hacker News new | past | comments | ask | show | jobs | submit login

What was bad about arc4random?



Nothing inherently wrong with it, but it's not available on all platforms that support Swift. The new Random APIs use arc4random() under the hood on Darwin IIRC.

There's also no direct equivalent to arc4random() in the new API - you always have to pass a range, which discourages people from using % to reduce the range and introduce modulo bias.


”but it's not available on all platforms that support Swift”

I think that’s a weak argument. arc4random’s source code isn’t platform specific, complex or large and is available under a permissive license, so they could easily put it in the runtime.

I would think they added this because of the modulo argument you give and to give it a better name (there’s nothing wrong with ‘arc4random’ for _a_ random number generator, but _the_ random number generator on a platform should have a simpler name)


Ah. Like Linux, I guess. Thanks for the info.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: