---
# System prepended metadata

title: 'WebHack 47: Transplant an Elm in your garden'

---

# WebHack 47: Transplant an Elm in your garden

## Common problems in modern web app developments

Requirement changes will come to the original "simple" API handling components and state management store.

During each small update to change the code per requirement, it is common that developers introduce new bugs only can be discovered when the user is using the product.

Bugs like racing states, missing branch of catching errors and so on, are so common and do adding cost to the development team.

Defining types won't help most of these issues. Since type system in most of mainstream lanaguages cannot make states, effects as types.

Therefore, compilers cannot check things like impossible states which are combined by multiple states flags. It means the system, the language and product allow developers to write buggy code that generates impossible states.

A compiler cannot prevent bugs means we are asking developers to handle and test every possible situation. In modern web apps, which is impossible due to the complexity of state management.

Sometimes, even APIs don't respect spec. Like API can abuse one field for putting different meanings in the same place. Like a same text field can be a URL in normal responses, or an error message when there are some errors.

## Elm can help web developers

1. A more powerful language and type system to express states and API contracts  (e.g. Algebraic Data Types vs discriminated union)
2. Defined safe and unsafe worlds, while the former is guaranteed by Elm compiler and Elm runtime
3. It checks all possible cases and branches, so developers won't miss any conditions that lead to bug during iterations of refactoring

One extra benefit is: it doesn't bring too much FP ideas to the daily development. 