5 ms·
Optimistic UI and Reactive Programming with Elm
- vvanders 11y agoThe one thing I really like in react is the composability. I haven't seen a mechanism a nice in elm like the virtual dom. It seems like things are much more verbose with one-way signals. That said I really like the rest of the language.
- masklinn 11y ago> I haven't seen a mechanism a nice in elm like the virtual dom. It's not quite clear what you mean, the "view" function of a standard Elm application is a virtual dom, elm.html is implemented on top of the virtual-dom library[0]. If you mean component, as far as I understand in Elm you'd use separate models and sub-functions in separate modules for each concern ("component")[1]. Elm subscribes to the "single point of truth" philosophy[2] so there isn't really a sense of component-local state or lifecycle. [0] https://github.com/Matt-Esch/virtual-dom https://github.com/Matt-Esch/virtual-dom [1] https://gist.github.com/evancz/2b2ba366cae1887fe621#nesting https://gist.github.com/evancz/2b2ba366cae1887fe621#nesting [2] like Om except more so
- vvanders 11y agoThanks, that makes it a bit clearer. I really just need to spend some proper time with elm.
- spuz 11y agoAlso, I'd recommend reading the Elm Architecture Tutorial[0]. It shows how to separate your code into modules with view/model/update sections and how this separation naturally leads to composable components where parent-child relationships are created simply by delegating the view calls from parent module to child module. [0] http://elm-lang.org/guide/architecture http://elm-lang.org/guide/architecture
- mateuszf 11y agoDoes it also have a diff mechanism and rerenders on "state" changes?
- spuz 11y agoYes see this post that explains how html works in Elm: http://elm-lang.org/blog/blazing-fast-html http://elm-lang.org/blog/blazing-fast-html
- skybrian 11y agoComposition of components in Elm is still being worked out, to judge by discussions on the mailing list [1], [2]. To do things like animating components, you still need to store the temporary state somewhere. [1] https://groups.google.com/forum/?fromgroups#!searchin/elm-discuss/composition%7Csort:date/elm-discuss/4sAbCc6HmVM/8b40G0aNpmwJ https://groups.google.com/forum/?fromgroups#!searchin/elm-di... [2] https://groups.google.com/forum/?fromgroups#!topic/elm-discuss/ZJ6lkfPimW8 https://groups.google.com/forum/?fromgroups#!topic/elm-discu...
- HOLYCOWBATMAN 11y ago>The one thing I really like in react is the composability. I haven't seen a mechanism a nice in elm like the virtual dom Im not familiar with react, and im not quite sure what you mean by that, but elm html is based on virtual-dom... http://elm-lang.org/blog/blazing-fast-html http://elm-lang.org/blog/blazing-fast-html
- marknutter 11y agoWhy does the virtual DOM have anything to do with composability? The virtual DOM is a mechanism that works under the hood to provide diffing that doesn't rely on expensive DOM operations, and thus should be completely transparent to the developer. Composability is purely a syntax thing, provided by JSX, and has existed in other frameworks with components for years (Angular, Ember, etc).