Hacker News new | ask | show | jobs
by pmontra 427 days ago
It's strange that they didn't write about the Erlang /Elixir approach of

1. returning a tuple with an ok or fail value (so errors as values) plus

2. pattern matching on return values (which makes error values bearable) possibly using the with do end macro plus

3. failing on unmatched errors and trying again to execute the failed operation (fail fast) thanks to supervision trees.

Maybe that's because the latter feature is not available nearly for free in most runtimes and because Erlang style pattern matching is also uncommon.

The approach requires a language that's built on those concepts and not one in which they are added unnaturally as an afterthought (the approach becomes burdensome.)

Pattern matching: https://hexdocs.pm/elixir/pattern-matching.html

With: https://hexdocs.pm/elixir/1.18.1/Kernel.SpecialForms.html#wi...

Supervisors: https://hexdocs.pm/elixir/1.18.1/supervisor-and-application....