|
|
|
|
|
by valcron1000
495 days ago
|
|
As someone who worked with Haskell and Rust in production this is a nightmare:
- All functions end up returnig `Either/Result`
- Stack traces are gone
- Exceptions and panics can still creep so it's not even "safer"
- There is no composability of different result types, you need something like `Either<FooError | BarError | ..., A> which is not supported in most languages (I think Scala 3 and Ocaml have this feature), or you create a "general wrapper" like `SomeException` (Haskell) or use `anyhow` (Rust). Today I write C# at my job and I could not be happier with the usage of exceptions. |
|
> Exceptions and panics can still creep so it's not even "safer"
This part is just as true for checked exceptions - you still have unchecked exceptions too. Ultimately you can't get away from needing a way to bail out from unrecoverable states. But "secondary state that is recoverable and understandable, but should be handled off the primary codepath" is a very useful tool to have in your vocabulary.
> Today I write C# at my job and I could not be happier with the usage of exceptions.
How do you do e.g. input validation? Things that are going to be 4xx errors not 5xx errors, in HTTP terms. Do you use exceptions for those? (I note that C# doesn't have checked exceptions at all, so there's no direct equivalent)