Hacker News new | past | comments | ask | show | jobs | submit login
Optimistic UI and Reactive Programming with Elm (athiemann.net)
67 points by agrafix on July 26, 2015 | hide | past | favorite | 9 comments



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. It seems like things are much more verbose with one-way signals.

That said I really like the rest of the language.


> 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

[1] https://gist.github.com/evancz/2b2ba366cae1887fe621#nesting

[2] like Om except more so


Composition 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-di...

[2] https://groups.google.com/forum/?fromgroups#!topic/elm-discu...


Does it also have a diff mechanism and rerenders on "state" changes?


Yes see this post that explains how html works in Elm: http://elm-lang.org/blog/blazing-fast-html


Thanks, that makes it a bit clearer. I really just need to spend some proper time with elm.


Also, 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


Why 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).


>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




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: