3 ms·
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 lis
by zachrose 8y 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.
- deleted 8y ago[deleted]
- k__ 8y agoYou 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.
- technion 8y agoDespite 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.
- _greim_ 8y agoOne 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.
- zachrose 8y agoYes, 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.
- skosch 8y agoSimilar 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.
- sridca 8y agoAnd then you move to Haskell from Elm. https://haskell-miso.org/ https://haskell-miso.org/ https://reflex-frp.org/ https://reflex-frp.org/
- dan-robertson 8y ago> 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)
- tabtab 8y agoI'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.)