Hacker News new | ask | show | jobs
by zachrose 2807 days ago
One intuition I’ve had while learning Elm is that it’s a fundamentally simpler language with a smaller number of concepts to learn than JavaScript.

In this list of 33 JavaScript concepts, I count 11 that either do not exist in Elm or, like Object.assign, do not have an alternative to worry about:

No reference types

No type coercion

No == vs ===, although typeof has a simpler equivalent

Basically all expressions and no statements

No hoisting as such

No prototypical inheritance or prototype chain

No Object.create, no destructive alternative to Object.assign

No factories or classes as such

No inheritance or polymorphism

No design patterns as such, though you could argue that abstract algebra or category theory are the replacements

No this, call, bind, or apply

The finer points of these are somewhat debatable, but overall my contention is that removing mutation and local state makes a lot of related concepts just fall away. A takeaway is that when someone tells you that they’ve learned Elm, you needn’t assume that this was as huge of an undertaking as learning JavaScript.

4 comments

> No == vs ===, although typeof has a simpler equivalent

Sure, but elm has its own issues with comparison as these are essentially implemented as a compiler hack, and only comparable (ie primitive or lists/tulles thereof) types can be used as keys for the built in map type (so you need to know about primitive types too)

I'm sorry, but any language that has to rely on "===" to know what's in what is usually fundamentally screwed up. (Yes, I'll probably get downvoted for this. Oh well, truth often ain't popular.)
One thing I've found with functional programming (Elm) is that writing JS requires constant mental effort. E.g. dynamic types, mutations, side effects, state. In Elm all of that neural machinery becomes obsolete, but your brain doesn't just magically switch it off. So Elm feels hard at first, until the concepts sink in a little bit and your brain re-wires itself.
Yes, this very much describes my experience of working on a gigantic Backbone app while using Elm at home. Work has gotten harder because I’m (rightfully) paranoid about mutation and unable to trust the (fallible) conventions of OO JavaScript.
Similar situation here – I've found that using Typescript and declaring (most) variables const already goes a long way, although the peace of mind still isn't quite the same.
You don't need all of these concepts on an everyday basis.

If you don't use ES5 stuff that was replaced in newer versions, things get much simpler.

let, =>, === etc.

Despite the submitted title containing "to help developers master", the actual Github page title contains "every JavaScript developer should know."

I think that casts this post in a different light. If the repo's intent is that "every JS developer should know" everything on this list, the context of this discussion changes.

And then you move to Haskell from Elm.

https://haskell-miso.org/

https://reflex-frp.org/