Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unidirectional dataflow is nice, but how do you figure out what parts need updating? And is all the bookkeeping necessary to figure that out not expensive?


You make it explicit in the system. I don't use React, but I do dabble with functional reactive programming. In an FRP system, you define a directed acyclic graph of values, where the edges are dependencies from one value to another. So, when an event enters the system at one of the graph's roots, only the things that depend on it will be updated.

Furthermore, you can avoid unnecessary re-computation via the usual techniques like memoization. One of the big advantages of the "virtual DOM" is that we get to build documents using a real programming language, not some HTML templating system.


Explicitly building a dependency graph is cumbersome. I'd rather see my programming language (compiler) building it implicitly as the program runs.


What? It's no different than saying which inputs are passed to a function. Also, languages with macros can add some nice syntactical sugar on top. JavaScript, of course, doesn't have a macro system so there's not much we can do there in that regard.


> It's no different than saying which inputs are passed to a function.

In that case, why isn't it just (more or less) equal in syntax to a function call?

Why do I need to build a graph, where a functional language would just let me build it implicitly.


Just keep updating everything on every input event! Sounds crazy but with virtual DOM it should be pretty doable at least for prototypes.

https://github.com/unframework/vdom-live




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

Search: