Skip to content

badlydrawnrob/elm-playground

Repository files navigation

README

πŸ“… It's super easy to forget so aim to practice once per week!

This is the killer. If I step away from programming for a few weeks, you really feel the rust gathering. This repository is a testing ground for all things Elm, and it's a year-long learning curve to get building.

There's plenty of javascript guides out there, so here the focus is on a statically typed functional style that turns you into a good programmer. For a study aid, you can use Anki flashcards and these handy guides to get you started. It's great for revision, but no substitute for building things.

πŸ”° Beginners

Elm is great for learning how to engineer.

Start with How To Design Programs and follow that up with Elm. It's better designed, more consistent, with better compiler error messages than Python.

After these two languages you'll have a decent grounding in Computer Science theory, and they're not too academic. I'm rubbish at maths, and am mostly focused on rapid prototyping, so I like to avoid deep academic learning. An artist ships!

πŸš€ Getting started

My goals are not the same as yours; have a clear vision! This can change as you go. β€” [#! Here would be a great place for a book!]

Here are my goals:

  1. Prototyping a business model
  2. Write as little code as possible1
  3. Teaching beginners

If I were to start over and learn again, I would:

  1. Start with HTDP and then Elm
  2. Learn only a subset of CompSci2 (first two chapters of HTDP, for example)
  3. Learn the best practices for http servers, json and REST APIs
  4. Learn how to use Ai as a teacher, or for pair-programming
  5. Learn from a mentor (good habits and what not to do)
  6. Learn how to frame and structure your learning (fail fast, just build!)

Basic commands

# Initialise an Elm project
elm init

# Install a package
elm install elm/<package>

# Make a HTML file from an Elm one
elm make src/Main.elm

# Compile to javascript file
elm make src/Main.elm --output=app.js

# View in the browser
elm reactor

⭐ Why Elm, then?

Types and inference

Why do we need types? It's best illustrated by the old joke ...

A programmer's wife told him "Go to the store and buy milk and if they have eggs, get a dozen." He came back a while later with 12 cartons of milk!

Beautiful error messages

This is where Elm really shines, everything is easy to install and just works! Unlike Python, where there's many ways to manage packages, the error messages are cryptic, and so on.

How to document your code

Testing

I'm lazy, and rarely test, but it's good practice to.

This mindset will land you in trouble if you're using Python, or a language that doesn't have strict typing. It's always wise to test your functions somehow, as typing only gets you so far. For example, I use Bruno when testing my APIs, but I don't write unit tests. Remember, Elm only checks for data types; it won't make sure your inputs and outputs are what you'd expect.

My goal is prototyping, so I'm a little lax, but for large programs with bigger teams, a lot can go wrong without tests! Always check your programs as your visitors would use them.

Learning Elm

πŸ“š Some useful docs

See your offline books in Library/code/elm!

πŸ§‘β€πŸ« Online courses

🎞️ Helpful talks

  1. Life of a file
  2. Teaching Elm to beginners
  3. Scaling Elm apps
  4. Making impossible states impossible3
  5. Make data structures
  6. From Rails to Elm and Haskell

πŸ“– Books

πŸ› οΈ Some tools

❓ Some helpful FAQs

Some nice examples

Larger programs

Footnotes

  1. Meaning efficient with my time, not lazy (ok, a little lazy). A simple route with less code and complexity? I'll take it. Take this carousel in Elm, for example. Want to be a great programmer? Go ahead, take your time! Prefer the easy route? Use scroll-snap with CSS. It all depends on your vision: I'd rather have more time to pursue other things, keep things simple. ↩

  2. A lot of programming books can be highly academic, and although books like these can be very thorough (and suit some learning styles), for me that was the wrong approach. For example, learning how to code recursively can be intellectually stimulating and it teaches you a lot, but after a certain point, it provides diminishing returns. It's hard to know exactly what you need to learn, but if your goal is to build things, aim for industry knowledge and pragmatic goals, rather than academic ones. Learn the basics well and start building things. You'll learn a lot along the way (with help from mentors), and you can do the heavier academic texts later if you enjoy that kind of thing! ↩

  3. All (or most) of Richard Feldmans talks ↩

  4. I'm lazy, and not a proper programmer, so I rarely write unit tests. This isn't the correct way, but Elm types give you quite a lot of guarantees, and I test the program as a regular user (or QA) might do. If any bugs arise, a visitor can raise a ticket and tests can be written. ↩

  5. There's an alternative by Dwayne called Elm Conduit ↩

About

A repo for Elm tutorials, projects and tests

Resources

Stars

Watchers

Forks

Packages

No packages published