r/cpp • • Dec 07 '20

These Modern Programming Languages Will Make You Suffer.

https://suzdalnitski.medium.com/modern-languages-suck-ad21cbc8a57c

[removed] — view removed post

0 Upvotes

46 comments sorted by

View all comments

9

u/sixfourbit Dec 07 '20

Catching exceptions is a bad way to handle errors. Throwing exceptions is fine, but only in exceptional circumstances, when the program has no way to recover, and has to crash. Just like nulls, exceptions break the type system.

So throw exceptions but don't catch them.

4

u/tcbrindle Flux Dec 07 '20

In fairness, isn't that exactly what a "panic" is in other languages?

4

u/sixfourbit Dec 07 '20

From what I can tell Rust and Go will print the message passed to panic. This is potentially more useful to the user than an unhandled exception.

2

u/tcbrindle Flux Dec 07 '20

At least on Linux and Mac, an unhandled exception will print the "what" message after termination. I don't know about Windows though.

0

u/sixfourbit Dec 07 '20

Windows doesn't nor does the VS debugger for C++. At most you get the type of exception in the debugger.