Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, I thought rand()'s self-locking was pretty common knowledge, but it is a good example to teach the perils of multithreading because its signature gives no indication that anything bad will happen. strtok() is even worse.

C++11's excellent <random> library represents the PRNG as an object like it should. Besides making the statefulness of PRNGs explicit, its API encourages correct usage - it would be more work to share a PRNG between threads.



strtok() is even worse. (Because it has global state)

There are a lot of C standard library functions from the 1970s that should have been moved to a "deprecated" library around 1990 or so and phased out by now.


Throw zero-terminated strings away too, please. Scanning sequential bytes is very slow and has caused so many bugs.




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

Search: