News for hackers. Stuff that matters.
Re:Misra C++:2023 Published by shadowgovt on Sunday December 17, 2023 @01:25PM (#38675034)
It depends on the problem domain. For automotive embedded software? Definitely not. But Google, for instance, bans them in much of its server code under the principle that exceptions should denote circumstances where the entire program cannot recover and when a server node cannot recover, logging noisily and failing fast so that it can be restarted into a working state is preferable to trying to unwind a bad state.

Given that constraint, they conclude that the overhead of maintaining exception unwinding and the non-local control flow aren't worth it.

Re:Misra C++:2023 Published by cpgxiii on Sunday December 17, 2023 @03:06PM (#38675909)
The classic GSG prohibition on exceptions has more to do with a lack of exception safety in their legacy code base than anything else. Promptly-crash-on-failure can be achieved by adopting a "don't catch exceptions" style, with significant advantages of not throwing away much of the strengths of RAII or needing the evil hack that is two-phase initialization.
Re:Misra C++:2023 Published by shadowgovt on Sunday December 17, 2023 @04:40PM (#38676725)
You can for all intents and purposes avoid two phase init with factory functions (which is how Go does it) and private constructors.

(To my memory though, Google didn't throw away the benefits of RAII without allowing exceptions... They discouraged complicated behavior in constructors and so the only thing a constructor could fail on was OME, which was supposed to crash anyway).

Re:Misra C++:2023 Published by otabdeveloper4 on Monday December 18, 2023 @03:33AM (#38680325)
All Google code is a huge antipattern and an example of enterprise coding gone insane.