Hacker News new | ask | show | jobs
by Rarebox 1578 days ago
There's very little you need exceptions for with STL. Data structures, algorithms, etc. all work just fine without exceptions.

C++ without exceptions is great. Google doesn't use exceptions and they still use STL. Gamedevs usually don't use exceptions and they're fine. Just use some other mechanism for errors, like error codes, absl::Status, std::expected, etc.

3 comments

Google did not do exceptions due to legacy code base reason, in its announcement it says for new code it will do exception, it just had too many old code and can't do exceptions.

Most STL operations and iteration etc will throw exception for errors, if you disable exception, any of those errors, be it recoverable or not, will just std::terminate, which might not be ideal.

Note Google explicitly configure runtime to instantly crash on memory allocation errors. With that STL works indeed nicely without exceptions.
I interviewed at Google once and during some whiteboard forgot to check malloc for NULL return, then mentioned, "oh yeah at <former company> malloc never returns NULL" and the interviewer commented "at Google, malloc spawns a new data center."
Gamedevs usually don't handle any errors at all.