Hacker News new | ask | show | jobs
by coffeeindex 328 days ago
Seems a bit strange to posit fault tolerance as an alternative to a type system. Personally, I view type systems as a bonus to DX more than something strictly designed to prevent errors
1 comments

It's in line with the erlang philosophy of letting things crash trivially and restart instantly. Due to the universal immutability, starting a new process from a given state in Erlang/Elixir is nearly instantaneous and has extremely little overhead as they are not OS threads, they are BEAM VM threads.

Very opposite the Go model, btw.

Letting you wrong computations crash does not make them right.
LOL. This only makes sense if you can know all the ways your code will fail... which you cannot.

Erlang/Elixir's approach is to simply say, "It's gonna fail no matter how many precautions we take, so let's optimize for recovery."

Turns out, this works fantastically in both cellphone signaling, which is where OTP originated, as well as with webserving, where it is perfectly suited.

I don't know who are arguing with? Everyone loves the otp.

It just does not catch logics errors.

whether that matters or not depends on whether the logic error occurs because of a rare combination of events or as a result of a certain state and whether that state remains after recovery. if there is for example a logic error that causes the app to crash after say 10 minutes of runtime, or eg. at a certain message size, then a recovery will reset the runtime and it will work again. it will of course invariably fail again after another 10 minutes or when the same message is resent, because it is a logic error, and logic dictates that the error won't go away no matter how often you restart, but it will work in the meantime.

in other words, any error that doesn't occur right at start can be recovered from at least for all those operations that do not depend on that error being fixed.

This sound like a wild and very contrived argument.

Both because that memory leaks are normal is types languages - and does usually not matter in most serious applications - and because this class of errors is usually not what types catch.

Types have value when you 1) refactor and 2) have multiple people working on a code base.

The error you see when you don't have types is something like a BadArityError.

To restart and fail again? How does that help with logic errors caused by wrong type objects?
It doesn't prevent the error, but it also won't take down your server when malicious users (or just lots of normal users) start to bang on that input with the problem, and your non-BEAM VM pool starts to run out of available preloaded stacks... You get a new Erlang process in well under a millisecond on modern hardware

It WILL log the error, with a stacktrace, so you have that going for you

Note that even with typing, you cannot avoid all runtime errors

Also note that this tech was first battle-tested on cellphone networks, which are stellar on the reliability front

Depends on the error. Lets say it is an error that happens once every 1 million users.