Don't "let it crash", let it heal
18 days ago
- #Error Handling
- #BEAM
- #Elixir
- The phrase 'let it crash' in Elixir is often misunderstood and can encourage bad habits.
- Elixir runs on the BEAM VM where code executes in lightweight, share-nothing processes that can restart upon crashing.
- Crashing in Elixir refers to individual processes, not the entire application, which remains stable.
- The 'let it crash' philosophy can negatively impact user experience and code quality by oversimplifying error handling.
- Processes in Elixir are tied to real-world operations like HTTP requests or database connections, making crashes impactful.
- Instead of always crashing, Elixir developers should represent failed states to users with actionable feedback.
- A middle-ground approach is recommended: crash on unrecoverable errors but handle recoverable ones gracefully.
- The BEAM's true strength is not just in letting processes crash but in their ability to recover and restart ('let it heal').
- Error tracking tools can help decide which errors to handle and which to let recover.