Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elm

sporto
November 22, 2015

 Elm

Elm for building single page applications

sporto

November 22, 2015
Tweet

More Decks by sporto

Other Decks in Technology

Transcript

  1. DESCRIBE STATE 1 2 3 1 2 3 focus on

    the state not the changes jquery react
  2. ALL STATE IN ONE PLACE ▸ State consistency between views

    ▸ Undo ▸ Serialise / unserialise ▸ Easier to debug
  3. ELM ▸ Immutable ▸ One state tree ▸ Stateless views

    ▸ Describe transformations ▸ Unidirectional data flow
  4. KEEPING STATE - THE FUNCTIONAL WAY Initial state FoldP Update

    Signal with event Signal with updated model like reduce
  5. ELM 7| text (toString List.lenght things) `List` does not expose

    `lenght`. Maybe you want one of the following? List.length
  6. RUBY undefined method '*' for nil:NilClass (NoMethodError) RUST panicked at

    'index out of bounds: the len is 1 but the index is 1' ELIXIR (ArithmeticError) bad argument in arithmetic expression GO panic: runtime error: index out of range https://gist.github.com/sporto/77db9de59f559e67b006
  7. ELM list = [] first = List.head list res =

    first * 2 main = text (toString res) This won't compile
  8. ELM list = [] first = withDefault 1 (List.head list)

    res = first * 2 main = text (toString res)
  9. FLOW & TYPESCRIPT ARE GREAT BUT NOT AT THE SAME

    S Still plenty of error that can slip through
  10. IN JS SIDE EFFECTS CAN HAPPEN ANYWHERE ▸ Impossible to

    know what side effects this have without looking ▸ Mutation, sending ajax? ▸ Makes really hard to find bugs sort(collection)
  11. IN ELM IS OBVIOUS sort: List String -> List String

    update: Action -> Model -> Effects Action
  12. ELM MAKE ▸ Compile on demand - really fast ▸

    Plays nicely with existing JS App (Embedded)
  13. JSON ENCODING / DECODING ▸ Bit awkward (as with any

    static language really) STRUCTURING AN APP ▸ Just different, takes time to understand FEW LIBRARIES ▸ Small ecosystem e.g. router, date picker, etc