Exceptions are bugs
Blog post from Momento
Kenny Chamberlin's blog post discusses the challenges and proposed solutions for handling exceptions in programming, particularly focusing on languages like Kotlin, Rust, and C++. He reflects on his experiences with exception handling in languages such as C# and Java, noting the difficulties in ensuring bugs are addressed, particularly in Java's approach to exceptions. Chamberlin advocates for a design philosophy where errors are treated as return values rather than exceptions, promoting compiler-enforced correctness and reducing the need for developers to handle exceptions manually. This approach, which he refers to as "Exceptions Are Bugs," emphasizes using the type system to model possible outcomes, encouraging developers to write robust and error-resistant code. The post highlights how various languages have incorporated features to support this paradigm, such as Rust's Result<> and Option<> and Kotlin's sealed types. Chamberlin suggests this method results in clearer, safer, and more cooperative development, despite potentially requiring more code and adaptation in languages that do not yet fully support pattern matching.