I Am Bismark

Let it crash

After over three years of programming in Elixir I think I finally understand the “Let it crash” principle. I realized just how much code was being wasted gracefully handling errors that had no business being handled at all!

Basically my thinking goes like this:

If there is a meaningful error I can return to a user e.g. “bad auth token”, I should handle this gracefully and return the error. Otherwise, “let it crash”!

If the database returns something I don’t expect, crash! If S3 is down, crash! If a map doesn’t have a key that should be there, crash!

The beautiful thing about crashing: I can see exactly what happened and where in the form of a stacktrace in the logs. If I attempt to handle something unexpected gracefully, the real issue is either shifted somewhere else OR it’s swallowed completely.

This has dramatically improved my code by removing unneccesary error handling, making everything more concise and readable. I only care about the happy path!

After one year at HelloSign and many huge features later, I’m very proud that I still have a net negative 20k lines of code in the repo. I think embracing “let it crash” is one of the biggest factors in this!

- Archive -