News for hackers. Stuff that matters.
Re:The Future of JavaScript MVCs by sebmarkbage on Thursday December 19, 2013 @03:37PM (#6937668)
React does the diffing on the output (which is a known serializable format, DOM attributes). This means that the source data can be of any format. It can be immutable data structures and state inside of closures.

The Angular model doesn't preserve referential transparency and therefore is inherently mutable. You mutate the existing model to track changes. What if your data source is immutable data or a new data structure every time (such as a JSON response)?

Dirty checking and Object.observe does not work on closure scope state.

These two things are very limiting to functional patterns obviously.

Additionally, when your model complexity grows, it becomes increasingly expensive to do dirty tracking. However, if you only do diffing on the visual tree, like React, then it doesn't grow as much since the amount of data you're able to show on the screen at any given point is limited by UIs. Pete's link above covers more of the pref benefits.

Re:The Future of JavaScript MVCs by Joeri on Friday December 20, 2013 @05:25AM (#6940756)
So, maybe i'm misunderstanding, but, the perf advantage is that react waits until the next RAF and then only updates the parts of the DOM that actually changed? So, now i'm wondering: why can't the browser do that? Isn't this whole middle-man approach something to eventually be optimized out?
Re:The Future of JavaScript MVCs by peterhunt on Monday December 23, 2013 @11:15PM (#6958176)
The browser does do this already to an extent.

The difference is that React constrains the operations a user can do (i.e. we only give them the DOM node if they explicitly ask for it and only let them manipulate it at certain times) so we eliminate the operations that cause the DOM to be slow.

If the DOM were to implement this it'd have to break backwards compatibility.

Re:The Future of JavaScript MVCs by polarix on Saturday December 21, 2013 @03:09AM (#6946156)
Sure, the browser could implement a virtual dom and then sync it and do a reflow once per frame.
Re:The Future of JavaScript MVCs by fbender on Sunday December 29, 2013 @05:07AM (#6979076)
You can do that with the help of `document.createDocumentFragment()`.