Hacker News new | ask | show | jobs
by Lord_Zero 427 days ago
This is called the "result pattern". I would not call this a novel concept. In C# we use this: https://github.com/ardalis/Result
1 comments

Yes, I stopped reading at:

> The most common approach is the traditional try/catch method.

Weird to stop reading at a statement that is factually true.
Returning error codes was actually the first approach to error handling. Exceptions (try/catch) became widespread much later. The article got it backwards calling try/catch "traditional" and Go's approach "modern".
Typed try/catch was tried in Java. The typing was not well liked and people voted with their feet to untyped exceptions. Euphoria turned to misery and golang emerged with returning errors explicitly. Overall I would say that the return value and error value shouldn't be split as in Golang. A result type that forces the user to account for the error when accessing the return is a much better approach. The compiler should make it fast.
> Exceptions (try/catch) became widespread much later

Exceptions, complete with try-catch-finally, were developed in the 60s & 70s, and languages such as Lisp and COBOL both adopted them.

So I'm not sure what you're calling "much later" as they fully predate C89, which is about as far back as most people consider when talking about programming languages.

Not in a codebase I develop or maintain. Nothing to see here, moving along.