Hacker News new | ask | show | jobs
by mFixman 1698 days ago
My least favourite example of bad C++ change is deprecating and removing the overload of `std::random_shuffle` that doesn't require a new random device and a random function [1].

Sure, that version was cryptographically insecure, but 95% of the use cases of shuffling have nothing to do with cryptography and don't need to be secured. This is not a case like PHP's `mysql_query` which has an easy replacement: now you must declare an `std::random_device` and `std::mt19937` and pass them to your functions.

This nearly made me fail a job interview in an embarrassing way.

[1] https://en.cppreference.com/w/cpp/algorithm/random_shuffle

1 comments

Apart from not being very random, it also wasn't thread-safe.
I think of the C++11 RNG stuff is thread safe, you need to lock around it or have an RNG per thread.