← the matrixruntime

Capability — runtime

Exceptions and error values

How a program says “this went wrong”.

Early languages signalled failure with a flag or a return code, and every call site had to remember to check. PL/I added the ON condition; Ada gave exceptions a type system and allowed them to carry values; Java made them checked, so the compiler would not let you ignore one.

Rust went the other way: no exceptions at all, just a Result the compiler insists you handle. That looks pedantic until you realise the question is not “how do we report errors” but “is the error visible at the point of the mistake”. Both answers are defensible; neither is accidental.

The trade-off

  • Exceptions hide control flow in the type system — the happy path is short, but the sad path is invisible to a reader.
  • Explicit error values cost a line at every level, and get ignored anyway the moment someone writes .unwrap().

Where it came from

PL/I in the 1960s, Ada in 1983 with typed exceptions, Java in 1995 with checked ones, Rust in 2015 with none.