5 ms·
I think the best way to become a better React developer is to learn Elm, and then build your React apps the same way Elm would have forced you to.
by yakshaving_jgt 4y ago
I think the best way to become a better React developer is to learn Elm, and then build your React apps the same way Elm would have forced you to.
- quickthrower2 4y ago… and Redux was born!
- yakshaving_jgt 4y agoQuite literally. https://redux.js.org/understanding/history-and-design/prior-art#elm https://redux.js.org/understanding/history-and-design/prior-...
- nnoitra 4y agoIsn't Redux only used when the app becomes too complex with really complex state?
- quickthrower2 4y agoI think so. Despite being an Elm fan I never used Redux. My side projects or work projects are small so local state and context were more than enough. Although Redux is like Elm, the language (Typescript or ES) make immutability hard so it doesn’t feel as natural a paradigm. Also pragmatically calling setState from an event is just easier for small projects.
- nnoitra 4y agoWhy is Elm mentioned specifically. As far as I know (state, action) => state is just a function without side effects?
- quickthrower2 4y agoElm is a pure functional language where all data is immutable and functions are pure meaning they are guaranteed to have no side effects. Having no side effects in JS is easy (just don't do it!) but immutability takes some effort. React requires immutability so that if it sees the reference to an object again, it knows that it contains the same data. If it promised to work when mutating objects it would continuously need to deep search inside them to see what changed. In JS, some array operations mutate the array, some copy it, you have to know specifically what operation you are using. In Elm, nothing mutates objects. All built in functions and functions you create will not do this. In short - you can do (state, action) => state in any programming language, but mistakes caused by mutations are impossible in Elm by design. Hope that makes sense.
- xedrac 4y agoOf course Elm is closely related to Haskell, which is a playground for category theory. I think learning the why behind it all can be useful in subtle ways.
- yakshaving_jgt 4y agoIt might be, but personally I don't know CT and I run my business on Haskell and have been writing Haskell professionally for most of my career now. So hopefully nobody is feeling intimidated by fancy mathy stuff. Haskell is just this cool, productive programming language.
- z5h 4y agoI gave an Elm talk years ago at the shared office space I used to work at. A few devs there later told me the talk helped them better understand React.