| > Assume that every statement can fail, and use some form RAII to manage resource cleanup. I think that's part of Chen's point: programmers just aren't good at doing this, they even get it wrong in published code samples. Exception-handling tends to become an afterthought, and even if you do pay attention to it, it's hard to get right. Chen is hardly alone in his scepticism. Exceptions are forbidden in the Google C++ style guide. They're also forbidden in certain critical-systems subsets of languages. Ravenscar Ada forbids exceptions, [0] as does Spark Ada (though in that case it's for a slightly different reason: it's difficult to formally reason about exceptions). edit Apparently the JSF C++ standard forbids exceptions, but MISRA C++ permits them provided certain guidelines are followed. I agree that RAII is very useful for robust exception-handling. > APIs can be organized to essentially force the use of RAII, even if popular but ancient APIs like POSIX file system are not designed that way Right, this is just the kind of thing C++ wrappers add (when wrapping C APIs). > Java/C# mechanism for running cleanup code 'try {} finally {}' a. fails to pass through a handle to the resource that needs cleanup Short of proper RAII (destructors), I'm not sure what that would look like. I'm not sure what Chen makes of destructors. They're non-local flow-control, but he seems to like them. Somewhat related: Zig's optional types, which essentially force the programmer to explicitly handle the case where the data doesn't exist. [1] Much more robust than the approach C takes, where the programmer is trusted to perform the check when necessary. [0] p20 of PDF: https://www.sigada.org/ada_letters/jun2004/ravenscar_article... [1] https://ziglang.org/documentation/master/#Optionals |