I'm simultaneously amused and concerned by the recurring proposals for Rust to add
1. exceptions
2. garbage collection
Sometimes in slightly modified forms or names, and often with very well-articulated, technically competent justifications (as is the case here).
Just say no!
necubi•44m ago
This doesn't have anything to do with exceptions, and the context appears to be Zig, not Rust.
The article is about how we represent errors not their control flow (i.e., exceptions).
stmw•28m ago
Fair point re: Zig vs Rust, but my larger point was about exceptions by any other name, in the linked article:
"Instead, when returning an error, rather than jumping to the return address, we look it up in the side table to find a corresponding error recovery address, and jump to that. Stack unwinding!
The bold claim is that unwinding is the optimal thing to do! .."
necubi•12m ago
If by "exceptions" you're talking about stack unwinding (as opposed to the language-level control flow constructs like throw/catch) then Rust has always had that with panics and panic=unwind.
MaulingMonkey•25m ago
Rust already has exceptions (when panic=unwind)
stmw•20m ago
But it's not really encouraged as it is in C++ or Java.
Quoting Rustonomicon:
"There is an API called catch_unwind that enables catching a panic without spawning a thread. Still, we would encourage you to only do this sparingly. In particular, Rust's current unwinding implementation is heavily optimized for the "doesn't unwind" case. If a program doesn't unwind, there should be no runtime cost for the program being ready to unwind. As a consequence, actually unwinding will be more expensive than in e.g. Java. Don't build your programs to unwind under normal circumstances. Ideally, you should only panic for programming errors or extreme problems."
fleventynine•41m ago
Rigid ABIs aren't necessary for statically linked programs. Ideally, the compiler would look at the usage of the function in context and figure out an ABI specifically for that function that minimizes unnecessary copies and register churn.
IMHO this is the next logical step in LTO; today we leave a lot of code size and performance on the floor in order to meet some arbitrary ABI.
layer8•34m ago
I would argue that most of today’s performance problems in software are unrelated to ABI.
stmw•26m ago
I would argue that is largely true because we got the ABIs and the hardware to support them to be highly optimized. Thing slow down very quickly if one gets off that hard-won autobahn of ABI efficiency.
stmw•53m ago
1. exceptions 2. garbage collection
Sometimes in slightly modified forms or names, and often with very well-articulated, technically competent justifications (as is the case here).
Just say no!
necubi•44m ago
The article is about how we represent errors not their control flow (i.e., exceptions).
stmw•28m ago
"Instead, when returning an error, rather than jumping to the return address, we look it up in the side table to find a corresponding error recovery address, and jump to that. Stack unwinding!
The bold claim is that unwinding is the optimal thing to do! .."
necubi•12m ago
MaulingMonkey•25m ago
stmw•20m ago