Live data from Hacker News

Optimistic UI and Reactive Programming with Elm

athiemann.net

1–10 of 10 posts

Re: Optimistic UI and Reactive Programming with Elm

#3
post #2

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

Re: Optimistic UI and Reactive Programming with Elm

#4
post #3
post #2

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 o…

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

Re: Optimistic UI and Reactive Programming with Elm

#5
post #2

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.

>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

Re: Optimistic UI and Reactive Programming with Elm

#6
post #3
post #2

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 o…

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

Re: Optimistic UI and Reactive Programming with Elm

#7
post #4
post #3

Earlier quoted context omitted.

> 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 o…

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

Re: Optimistic UI and Reactive Programming with Elm

#8
post #6
post #3

Earlier quoted context omitted.

> 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 o…

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

Re: Optimistic UI and Reactive Programming with Elm

#9
post #3
post #2

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 o…

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

Re: Optimistic UI and Reactive Programming with Elm

#10
post #2

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.

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