<story><title>Object.observe withdrawn from TC39</title><url>https://mail.mozilla.org/pipermail/es-discuss/2015-November/044684.html</url></story><parent_chain><item><author>haberman</author><text>I like the React model, but it does make one key assumption.  It assumes that DOM mutation is so slow that re-rendering and diffing the entire virtual DOM for every update is basically free in comparison.  I like the simplicity of React&amp;#x27;s approach, but this assumption makes me a little uncomfortable.</text></item><item><author>tolmasky</author><text>I now subscribe to the React-style &amp;quot;wait, why are you listening to anything?&amp;quot; mindset. However, if you&amp;#x27;re going to go down the mutable path, I think KVO was particularly well designed.&lt;p&gt;The main reason was that it made composition pretty sane and created clear places to handle changes. With KVO, you implement your KVO-compliant mutation methods, and all changes would then get funneled through there (most notable container ones). Compare the mess that is NSView (addSubview&amp;#x2F;insertSubview:positioned:relativeTo:&amp;#x2F;removeFromSuperview&amp;#x2F;etc) to the post-KVO NSTreeNode. NSTreeNode simply exposes .mutableChildNodes, which you treat as a normal array (addObject:&amp;#x2F;etc) and after adding a child, it then has parentNode set to the parent after. This was great for lots of reasons: 1. No need to re-create API, you just used NSMutableArray&amp;#x27;s existing API. So [someNode.mutableChildNodes removeObjectsWithPredicate:somePredicate] and all the parentNode relationships get handled for free. Compare this to pre-KVO methods where every time you wanted to take advantage of a neat NSMutableArray feature, you&amp;#x27;d have to re-expose it yourself like removeSubviewsWithPredicate:, or wind up having to copy out the array, mutate, then re-assign with setSubviews: 2. Less room for error since all your cleanup code just happens in removeObjectFrom&amp;lt;Key&amp;gt;AtIndex:, one funnel.&lt;p&gt;Again, I believe this to be a great local maxima for this style of programming, one that was never that fully explored since the move to more KVO-ness was eclipsed by the attention to iOS. I think most the problems are better solved through React&amp;#x27;s top-down approach.</text></item><item><author>pavlov</author><text>In my experience, observing individual properties on model objects just isn&amp;#x27;t very useful in real world apps. Cocoa has long offered &amp;quot;key-value observing&amp;quot; (KVO) for this purpose, but other mechanisms like notifications tend to be more practical, usually because listeners need some context in order to do the best thing in response to a change, and an individual property change won&amp;#x27;t carry any of that context.&lt;p&gt;Here&amp;#x27;s a practical example... Imagine an editor where an on-screen element is deleted. The controller might do a bunch of stuff such as:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  element.parent = nil
  scene.clearReferencesToElement(element)
  container.delete(element)
  self.selection = []
&lt;/code&gt;&lt;/pre&gt;
If there&amp;#x27;s a listener on &amp;quot;container&amp;quot;, it will get notified even before the selection was cleared. That&amp;#x27;s probably not the intention.&lt;p&gt;If we know that&amp;#x27;s going to happen, we could move the selection manipulation before the container access... But then we have fragile code that depends on implicit behavior in a model class. Always better to send an explicit event.</text></item></parent_chain><comment><author>nostrademons</author><text>React&amp;#x27;s assumption isn&amp;#x27;t actually true.  DOM manipulation is fast - all modern browsers use a dirty-bit system where modifying the DOM is basically a few pointer swaps.  &lt;i&gt;Layout&lt;/i&gt;, however, is slow, and dirtying the DOM requires &lt;i&gt;at least one&lt;/i&gt; layout as soon as control returns from JS.  If you intersperse measure and modify calls, it&amp;#x27;s more.&lt;p&gt;However, what is true is that:&lt;p&gt;1. Both JS and the DOM are fast enough that you can lay out most reasonable pages within the threshold of visual perception (~150-200ms).&lt;p&gt;2. If you need to layout the page during an animation frame, you&amp;#x27;re hosed anyway.  You have a frame budget of 16.67ms and layout will take 100ms+ on mobile.&lt;p&gt;And so the practical, qualitative conclusion is the same: you can use React for your basic page transformations &amp;amp; rendering, but you need to use CSS transforms and offload the work to the GPU if you want to have a prayer of making animations work on mobile.  And React also protects you from completely fucking up performance (which is trivially easy with JQuery), so many real-world pages from inexperienced webdevs experience a very significant speedup.</text></comment>
<story><title>Object.observe withdrawn from TC39</title><url>https://mail.mozilla.org/pipermail/es-discuss/2015-November/044684.html</url></story><parent_chain><item><author>haberman</author><text>I like the React model, but it does make one key assumption.  It assumes that DOM mutation is so slow that re-rendering and diffing the entire virtual DOM for every update is basically free in comparison.  I like the simplicity of React&amp;#x27;s approach, but this assumption makes me a little uncomfortable.</text></item><item><author>tolmasky</author><text>I now subscribe to the React-style &amp;quot;wait, why are you listening to anything?&amp;quot; mindset. However, if you&amp;#x27;re going to go down the mutable path, I think KVO was particularly well designed.&lt;p&gt;The main reason was that it made composition pretty sane and created clear places to handle changes. With KVO, you implement your KVO-compliant mutation methods, and all changes would then get funneled through there (most notable container ones). Compare the mess that is NSView (addSubview&amp;#x2F;insertSubview:positioned:relativeTo:&amp;#x2F;removeFromSuperview&amp;#x2F;etc) to the post-KVO NSTreeNode. NSTreeNode simply exposes .mutableChildNodes, which you treat as a normal array (addObject:&amp;#x2F;etc) and after adding a child, it then has parentNode set to the parent after. This was great for lots of reasons: 1. No need to re-create API, you just used NSMutableArray&amp;#x27;s existing API. So [someNode.mutableChildNodes removeObjectsWithPredicate:somePredicate] and all the parentNode relationships get handled for free. Compare this to pre-KVO methods where every time you wanted to take advantage of a neat NSMutableArray feature, you&amp;#x27;d have to re-expose it yourself like removeSubviewsWithPredicate:, or wind up having to copy out the array, mutate, then re-assign with setSubviews: 2. Less room for error since all your cleanup code just happens in removeObjectFrom&amp;lt;Key&amp;gt;AtIndex:, one funnel.&lt;p&gt;Again, I believe this to be a great local maxima for this style of programming, one that was never that fully explored since the move to more KVO-ness was eclipsed by the attention to iOS. I think most the problems are better solved through React&amp;#x27;s top-down approach.</text></item><item><author>pavlov</author><text>In my experience, observing individual properties on model objects just isn&amp;#x27;t very useful in real world apps. Cocoa has long offered &amp;quot;key-value observing&amp;quot; (KVO) for this purpose, but other mechanisms like notifications tend to be more practical, usually because listeners need some context in order to do the best thing in response to a change, and an individual property change won&amp;#x27;t carry any of that context.&lt;p&gt;Here&amp;#x27;s a practical example... Imagine an editor where an on-screen element is deleted. The controller might do a bunch of stuff such as:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  element.parent = nil
  scene.clearReferencesToElement(element)
  container.delete(element)
  self.selection = []
&lt;/code&gt;&lt;/pre&gt;
If there&amp;#x27;s a listener on &amp;quot;container&amp;quot;, it will get notified even before the selection was cleared. That&amp;#x27;s probably not the intention.&lt;p&gt;If we know that&amp;#x27;s going to happen, we could move the selection manipulation before the container access... But then we have fragile code that depends on implicit behavior in a model class. Always better to send an explicit event.</text></item></parent_chain><comment><author>tlrobinson</author><text>&lt;i&gt;&amp;quot;diffing the entire virtual DOM for every update is basically free in comparison&amp;quot;&lt;/i&gt;&lt;p&gt;If you use something like Immutable.js you can avoid a lot (most? all?) of the diffing since comparing trees of objects becomes a simple object reference comparison. This is common in the Om world, and becoming more popular in JS too.</text></comment>