[haiku-development] Re: Plan for NetServices Kit (v2)

  • From: Niels Sascha Reedijk <niels.reedijk@xxxxxxxxx>
  • To: Haiku Development <haiku-development@xxxxxxxxxxxxx>
  • Date: Thu, 2 Sep 2021 15:02:36 +0100

Hi,

On Thu, Sep 2, 2021 at 2:21 PM Ryan Leavengood <leavengood@xxxxxxxxx> wrote:


On Wed, Sep 1, 2021 at 10:41 AM Mr. waddlesplash <waddlesplash@xxxxxxxxx> 
wrote:

Having worked largely in codebases that do not use exceptions, perhaps
it's just my personal preference, but the more I work with exceptions
the more I dislike them as an error handling strategy. I think the
return-value-based error handling is by far the better way; certainly
it's cleaner in Rust where there is more compiler support for it (now,
whether we would want to try and imitate that in C++ without compiler
support is a separate question; I'm not sure that we should), but
overall, exceptions are "outmoded" in my opinion.

I agree about exceptions being outmoded. Most of the newer C/C++
replacement languages such as Rust, Go, Zig and Odin all use fairly
straightforward return value error handling with varying levels of
language support to make it more pleasant for the developer.

This point has some merit, but warrants nuances.

For example, Rust actually does have two error mechanisms. There are
the return value errors (usually wrapped up in the result type), but
there are also exception-type errors in the form of panics. Panics do
wind down the stack, and panics can actually be caught and handled!
Furthermore, there is an entire infrastructure built around having
return value errors propagate more easily down the stack in order to
handle them in central points (using helper crates like anyhow and
thiserror). These crates are actually a common practise especially in
larger projects, and do nuance 'exceptions as a concept are bad'.

I think it is also important to note that C++ has not backed down from
exceptions. Obviously the standards committee never says goodbye to
any feature, but it is definitely not the case that effort has been
put in to be able to use the standard library exception-free. So
arguably exceptions as a strategy is still very much alive.

Regards,

N>

Other related posts: