3 ms·
>Somehow after 25 years of coding I've never seen issues with using exceptions Here is a link to Google's C++ style guide, which discourages exceptions with pr
by nemothekid 5y ago
>Somehow after 25 years of coding I've never seen issues with using exceptions
Here is a link to Google's C++ style guide, which discourages exceptions with pros & cons:
https://google.github.io/styleguide/cppguide.html#Exceptions https://google.github.io/styleguide/cppguide.html#Exceptions
It's your 25 years of coding, vs the several thousand man-months of Google's C++ codebase. That said, I don't deny that some people use exceptions with little mental overhead. I've been told about very high performance and readable trading software that made use of exceptions. My main gripe is that it they require discipline to use correctly, almost everyone uses them differently, and they make code harder to reason about. I would prefer a language that doesn't need an IDE to locally reason about some piece of code.
- nprateem 5y ago"Things would probably be different if we were starting over from scratch" They concluded against them due to problems integrating into legacy code which is fair enough
- pjmlp 5y agoGoogle's style guide is well known in the C++ community for not being that much worth to look into it.
- kaba0 5y agoAs others mentioned, Google’s C++’s guide is simply not that relevant. And don’t forget the principle use case of C++ - it is a low level language. While exceptions are pretty cheap overall, they can be expensive in some niche cases which do happen more often in C++ than in python. I really haven’t heard a good case against exceptions per se — they make it possible to handle every error at an appropriate place. And bubbling the error up to possibly a much higher place is exactly the needed approach many times (e.g. returning a http error code on an unrecoverable mistake)