3 ms·
I like Elm a lot. I also do a lot of React and I have worried about picking Elm to avoid killing a nice product written in it because no one is willing to learn
by 0xCMP 9y ago
I like Elm a lot. I also do a lot of React and I have worried about picking Elm to avoid killing a nice product written in it because no one is willing to learn it to maintain it after I'm gone. Better to pick React to avoid any rewrites just to continue maintaining the product.
However, if they could just be convinced to learn Elm I'm positive that Elm would be much easier to maintain and improve than just React by its self. React can definitely be maintained easily, but Elm does a lot of the work to check itself and also enforces discipline that React can't (although you could get a lot by just using Flow extensively and treating its errors as blockers).
- mistersys 9y agoThe static types system is great, however, having used elm: elm unloads much of the work react does onto you. React automatically (with keys) manages state creation for lists and child components, but with elm you have to manage that manually. Using a component isn't simply matter of importing and using, you have to integrate its state into your component, send all it's events back to its reducer, and then map each child state to the corresponding view. You end up with lots of boilerplate.
- hathawsh 9y agoWould it be possible for Elm to evolve a way to let components keep internal state? The lack of component-local state is what ultimately drove me away from Elm for my last project. It seems like it should be possible, since Elm and Redux are vaguely similar and Redux can store component-local state if you need it to.
- boubiyeah 9y agoI don't see this happening. local state would invalidate many things in the Elm ecosystem like the time travel debugger, all the tutorials, etc. It's not such an easy problem, you have to write a new reconciler that only renders the things that have changed instead of always rendering the entire tree. btw, redux only deal with global state but encourages the use of local (setState based) state whenever it makes sense.
- fpoling 9y agoFrom my small experience with Elm all that boilerplate is nicely dealt by compression-oriented programming [1]. It is easy to move common code into helper function and Elm pure functional nature makes that rather maintainable. The hard part is to come up with good names for those helpers and avoid being too generic when refactoring code. [1] https://mollyrocket.com/casey/stream_0019.html https://mollyrocket.com/casey/stream_0019.html
- mistersys 9y agoI think the bigger problem here is the load it takes to change from stateless to stateful. Let's say a create a stateless subscribe button component, that's part a of a stateless header component. It just accepts a listener that is called when the button is clicked. Now, my designer wants me to add a dropdown menu to the subscribe button that allows people to enable email notifications. The dropdown menu needs state, so now I add a reducer and model to my subscribe button, I need to wire that up through the stateless header component making it stateful, then finally wire it into the the atom for the app. I ended up doing these chains of updates and adding parameters to add simple features. Also, elm lacks typeclasses. Try making a modular form builder with elm that allows other authors to define fields with custom state, it's a mess.