top | item 30431848

(no title)

Rarebox | 4 years 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.

discuss

order

synergy20|4 years ago

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.

_0w8t|4 years ago

Note Google explicitly configure runtime to instantly crash on memory allocation errors. With that STL works indeed nicely without exceptions.

lanstin|4 years ago

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."

kaetemi|4 years ago

Gamedevs usually don't handle any errors at all.