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

Stepping out of the chaos with Elm

Stepping out of the chaos with Elm

So many frameworks! The javascript world seems to have an explosion of tools, a new one appears every other day with the promise of revolutionizing the way you program. We have seen the rise and fall of giants, but we are somehow not significantly more productive than before. What can we learn from our past and change in our present? Enter Elm. Elm is a programming language for the web with the unparalleled combination of speed and maintainability that the javascript world is so much looking forward to have. This talk talks is about the three major aspects of Elm and why I think it is leads the only sane step out of the chaos we are living in the frontend world: Elm as a language and how it can drastically change the maintainability issue for javascript apps; Elm as a architecture and how having clear guidelines that are enforced by the language is a good idea; and Elm as a fast growing ecosystem of very high quality resources.

More Decks by José Lorenzo Rodríguez

Other Decks in Programming

Transcript

  1. TOO MANY LIBRARIES! ➤ When starting a project it is

    not clear what combination of libraries should be picked.
  2. JS IS EASY TO GET STARTED WITH ➤ But it

    is also difficult to maintain in the long run.
  3. JS IS EASY TO GET STARTED WITH ➤ But it

    is also difficult to maintain in the long run. ➤ A wide array of runtime errors can happen due to simple overlooks
  4. JS IS EASY TO GET STARTED WITH ➤ But it

    is also difficult to maintain in the long run. ➤ A wide array of runtime errors can happen due to simple overlooks
  5. JS IS EASY TO GET STARTED WITH ➤ But it

    is also difficult to maintain in the long run. ➤ A wide array of runtime errors can happen due to simple overlooks ➤ It is easier to come up with hacks for solving issues. Hacks are rarely documented.
  6. JS IS EASY TO GET STARTED WITH ➤ But it

    is also difficult to maintain in the long run. ➤ A wide array of runtime errors can happen due to simple overlooks ➤ It is easier to come up with hacks for solving issues. Hacks are rarely documented. ➤ TypeScript, flow, Rx, unit tests… they all help, but they are only used by people that understand their value.
  7. “What I want to do is: I want to get

    to this magic realm where we get that [insanely high] level of maintainability, but where we also have something usable. -Evan Czaplicki, creator of Elm
  8. A simple Elm program Module importing Defining a Value Defining

    a Function Calling a function with a value
  9. A simple Elm program Module importing Defining a Value Defining

    a Function Calling a function with a value
  10. Declare a new data type }Properties of the Person }

    Type annotation Takes the person argument and sets the property to newAddress
  11. Declare a new data type }Properties of the Person }

    Type annotation Takes the person argument and sets the property to newAddress This function actually returns a different person. It does not change the passed argument!
  12. YOU DON’T NEED TO TELL HOW THE DOM IS CHANGED

    just declare how it should look like
  13. Html is constructed declaratively First argument is a list of

    attributes Second argument is a list of children Html Nodes This builds a single <li>
  14. Html is constructed declaratively First argument is a list of

    attributes Second argument is a list of children Html Nodes This builds a single <li>
  15. Does the initial wiring for you we start the app

    with an empty list The view function in this file
  16. Does the initial wiring for you we start the app

    with an empty list The view function in this file }Defines the type of messages the app will get from the user
  17. Does the initial wiring for you we start the app

    with an empty list The view function in this file }Defines the type of messages the app will get from the user Pass the message on click
  18. Does the initial wiring for you we start the app

    with an empty list The view function in this file }Defines the type of messages the app will get from the user Pass the message on click
  19. }scopes variables to this function The message from the user

    The “model” (list of languages) } These are always safe operations. Even on empty lists
  20. }scopes variables to this function The message from the user

    The “model” (list of languages) } These are always safe operations. Even on empty lists Finally return the modified “model”
  21. }scopes variables to this function The message from the user

    The “model” (list of languages) } These are always safe operations. Even on empty lists Finally return the modified “model” The pipe is like the “.” operator in JS
  22. DO YOU REMEMBER THIS? Idea: It would be nice if

    we could have composable and reusable modules by only having to declare these 3 things.
  23. Declare a module with the TEA API Instead of hardcoding

    the languages. Make them dynamic Refactored the previous code to use helper functions
  24. We’ll have two list of languages. Here are the defaults

    The same pattern repeats, here’s the main program’s Model
  25. We’ll have two list of languages. Here are the defaults

    The same pattern repeats, here’s the main program’s Model Re-use the Model from the other module
  26. We’ll have two list of languages. Here are the defaults

    The same pattern repeats, here’s the main program’s Model Re-use the Model from the other module The messages are coming from either one list or the other. We distinguish them by “tag”
  27. We’ll have two list of languages. Here are the defaults

    The same pattern repeats, here’s the main program’s Model Re-use the Model from the other module The messages are coming from either one list or the other. We distinguish them by “tag” We can call this a “tag”
  28. We’ll have two list of languages. Here are the defaults

    The same pattern repeats, here’s the main program’s Model Re-use the Model from the other module The messages are coming from either one list or the other. We distinguish them by “tag” We can call this a “tag” We delegate the update logic to the sub-module
  29. We’ll have two list of languages. Here are the defaults

    The same pattern repeats, here’s the main program’s Model Re-use the Model from the other module The messages are coming from either one list or the other. We distinguish them by “tag” We can call this a “tag” We delegate the update logic to the sub-module
  30. Re-use the view from the other module Automatically tag events

    coming from this view Pass only the relevant data
  31. Re-use the view from the other module Automatically tag events

    coming from this view Pass only the relevant data Wire the application together
  32. Re-use the view from the other module Automatically tag events

    coming from this view Pass only the relevant data Wire the application together
  33. THE PACKAGING SYSTEM ➤ elm-package is the tool for sharing

    packages with the community ➤ Documentation in every package is automatically displayed online
  34. THE PACKAGING SYSTEM ➤ elm-package is the tool for sharing

    packages with the community ➤ Documentation in every package is automatically displayed online ➤ The packager will prevent you from publishing broken code
  35. THE PACKAGING SYSTEM ➤ elm-package is the tool for sharing

    packages with the community ➤ Documentation in every package is automatically displayed online ➤ The packager will prevent you from publishing broken code ➤ If you make an API change the packager will automatically bump the semantic version for you
  36. PLENTY OF RESOURCES AND HELP ➤ Elm was designed with

    usability in mind. Concepts are explained with clear examples in the guide.
  37. PLENTY OF RESOURCES AND HELP ➤ Elm was designed with

    usability in mind. Concepts are explained with clear examples in the guide. ➤ Plenty of example applications linked from the homepage
  38. PLENTY OF RESOURCES AND HELP ➤ Elm was designed with

    usability in mind. Concepts are explained with clear examples in the guide. ➤ Plenty of example applications linked from the homepage ➤ The best place to ask for help is the slack channel or IRC, where several hundred people hang out during the day.
  39. PLENTY OF RESOURCES AND HELP ➤ Elm was designed with

    usability in mind. Concepts are explained with clear examples in the guide. ➤ Plenty of example applications linked from the homepage ➤ The best place to ask for help is the slack channel or IRC, where several hundred people hang out during the day. ➤ Monthly @elmcph meet up in Copenhagen. Next one is tomorrow!!