DEV Community

Discussion on: How I (Finally) Built an App in Elm

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

It took me a couple of tries at F# (my first FP language, similar to Elm) before I could write in it, and a bit longer before I was writing using functional idioms. So don't feel bad. Elm (and FP)'s learning curve is harder compared to something like JavaScript, but it is worth learning. This is kinda the way I look at it in graphs.

Writing your first pure JS app is about like this. Super easy to start, but increasingly hard to recover from mistakes.
x squared graph

Writing your first Elm app is kinda like this (assuming no prior FP knowledge). Pretty hard to get started... maybe even have to "unlearn" some habits. But recovering from beginner mistakes (or changing requirements) is not particularly hard. Just normal work.
log x graph

Also note that there are built-in helpers for Maybe. Totally optional to use, but a little shorter.

blankQuestion =
    { question = ""
    , answers = []
    , correctAnswer = ""
    }

currentQuestion : Maybe Question -> Question
currentQuestion possibleQuestion =
    Maybe.withDefault blankQuestion possibleQuestion

-- or if you prefer

currentQuestion possibleQuestion =
    possibleQuestion |> Maybe.withDefault blankQuestion
Enter fullscreen mode Exit fullscreen mode

We use Elm in production, and I am very happy with that choice. In fact, we trained two devs without prior professional experience (but with CS education) to use Elm. They were writing in it after a couple of weeks and doing features after a month. I think immersion and going through the learning process with others helps. After 1 month, this was obviously not the greatest Elm/FP code, but Elm is quite amenable to refactoring once you learn a better way.

Collapse
 
aspittel profile image
Ali Spittel

Ah okay! I gave myself probably around 10 hours in total -- I'm not learning it for a job so it makes it harder to justify a huge time commitment! I do have Redux experience, though this was my first fully functional language. I was just proud that I had something working at the end! Maybe someday I will have more time to commit to learning FP more fully!

Collapse
 
eljayadobe profile image
Eljay-Adobe

If you do get to the point that you want to make another attempt at an FP language, and you have some interest in .NET, then I highly recommend F# and The Book of F# by Dave Fancher.

F# is essentially OCaml for .NET, created by Don Syme of Microsoft Research Cambridge.

Unlike Elm, it isn't a pure FP language. (To be a first-class .NET language, it has to support .NET's OO paradigm.) But like Elm, it puts FP front-and-center.