I disagree. In fact, I'd go a step further the opposite direction and say that the inclusion of panics was a mistake in the language design, though we're stuck with it now. To be fair, they do allow much better diagnostics when things fail, so this is more of a matter of simplicity vs developer economics, unless I'm missing something.
I agree that supporting panics was a mistake as long as exceptions aren't really supported. Panics force everyone to pay for the possibility of unwinding without getting to use unwinding for exceptions. It's unfortunate. If you're going to have to consider the possibility unwinding, running destructors, and so on, just add exceptions!
You don't need the panic mechanism to get good stack traces. You can get good stack traces in plain C with abort(): walking the stack does not require unwinding the stack! Confusing these two concepts is just another example of the unfixable confusion baked into the core of Rust that ruins an otherwise-interesting language.
If you don’t want to pay for landing pads, you can compile your program with panic=abort, and you won’t get them. As you say, you can still get stack traces.
The only reason that this is feasible is precisely because panics are not used for recoverable error handing in Rust; libraries don’t break if you turn this option on.
Well, panics should not be used for recoverable error handing in Rust. There's no guarantee turning off panics in favor of aborts wont break the assumptions of some library. That library should probably break tho, since as you said, panics aren't meant to emulate application logic exceptions.
use std::panic::catch_unwind;
fn main() {
let err = catch_unwind(|| { panic!("B") });
println!("Look ma, recoverable error handing! {:?}", err);
}
Can I go further and disable stack traces as well, without giving up entirely on std? I don't want my release builds to have any of the extra code required to walk the stack. Just let the app crash; if I want a stack trace, I'll use a debugger.
Almost all of the bloat you get for stack traces is the extra information embedded in the stack frames, which you still need if you want your debugger to be able to display stack traces. If you don't want them to get printed on panic, you can give it a custom panic hook that doesn't do the stack trace walk.