4 ms·
>What's the reason behind their prevalence in almost every language? Unexpected errors are inescapable when you consider OOMs and other things so its almost re
by jayd16 2y ago
>What's the reason behind their prevalence in almost every language?
Unexpected errors are inescapable when you consider OOMs and other things so its almost required to support that. Ending scopes and bubbling up an error without a ton of unwrap boilerplate is actually really compelling.
- astrange 2y agoOOMs are usually a bad thing to make into an error because there is no way to recover from them. You might as well just kill the process instead of making people try to handle it.
- saagarjha 2y agoFor OOM, sure. There are still plenty of errors that are often surprising, though–API calls that happen to, say, do XPC for example.
- dwaite 2y agoI'd also say there is a bit of a 'when you have a hammer…" going on. Java in particular spent a good portion of its formative years with relatively few language features, so there was a lot of cobbling them together in interesting ways to solve new classes of problems. Exceptions became a way to capture diagnostic context for where an error happened and a (limited) view of state, so a lot of Java server applications use them as part of their issue reporting and diagnosis process. Other languages may expect say the application to halt on unexpected errors, and to build tools to locally evaluate the core dump (such as crash reports and symbolication in Apple-land). This does have some influence on developers in terms of the ramifications of a failure (failed request vs stopped application/server), so it can have interesting effects in how seriously a team evaluates potential errors and designs for recovery/cleanup.