This is a basic guide on how to learn Elm rather than actually teach you. I'm going to mostly link to resources that I feel are valuable and try to "teach you how to fish".
The main purpose is to accelerate your learning and save you a lot of googling and weeding through bad explinations.
- Main website http://elm-lang.org
- Elm packages search and docs http://package.elm-lang.org
- Elm slack invite http://elmlang.herokuapp.com/
- Syntax Cheat sheet http://elm-lang.org/docs/syntax
- Elm code examples http://elm-lang.org/examples
- Automatic JSON decoders http://eeue56.github.io/json-to-elm/
There is many different ways to learn Elm. Pick the one that best suits your learning style. With that said I feel that an interactive, "real-ish" project approach to be especially effective for me.
Assuming you're familiar with JavaScript and reasonably familiar with functional programming you should:
- Read through the syntax guide
- Start with a basic project example that uses
Html.beginnerProgram
- Start making a prototype of something (default: to-do list) doing no JS interop or http requests.
- Refractor some things by changing the models type and following the compiler messages
- Pull out some of the larger parts into new files like
View.elm
etc... - Get to the point it's basically done except for a HTTP request and learn about JSON decoding. I recommend using this: http://eeue56.github.io/json-to-elm/ to do it automatically.
- If this path didn't work for you make an issue or tell me in some way
- Exercism http://exercism.io/languages/elm
- This is a great course (and free!) https://egghead.io/courses/start-using-elm-to-build-web-applications
- Elm seeds https://elmseeds.thaterikperson.com/
- daily drip (paid + a few free) https://www.dailydrip.com/topics/elm
- front-end masters course (paid)
- Main Elm book https://guide.elm-lang.org/install.html
- Elm in action (physical / eBook, paid) https://www.manning.com/books/elm-in-action
- 99 problems solved in Elm https://johncrane.gitbooks.io/ninety-nine-elm-problems/content/
- Elm tutorial https://www.elm-tutorial.org/en/
- Package documentation
- Search the Elm community FAQ
- Ask on the Elm slack
One of the first questions JS developers tend to have is how organize and keep code clean when growwing an Elm applicaiton.
Keep in mind that Elm is very different than JavaScript. For one thing there's no local state of any sort nor is there any direct way to do side effects. These are there to protect you and are part of what makes Elm code generally 100% runtime error free.
There's also not one cure-all way to organize your code like many frameworks encourage you to do. For instance, despite the Html.program
funciton being organized into view, update, model, subscriptions, etc... doesn't mean you have to organize your code that way. Do what makes sense for your domain. Don't prematurely optimize.
These are some basic rules to follow
- Make good models
- Hide implementaiton if it's complex
- Use the view to transform that into html
- If your program needs to change just modify the model and follow the errors till you've got a working app again.
- Remember, Elm makes it easy to fix your mistakes so don't sweat it too much.