TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

React and the economics of dynamic web interfaces

76 pointsby tbassettoover 9 years ago

4 comments

nevirover 9 years ago
Performance is often cited as the &quot;big win&quot; that React brings to web development; I really wish that wasn&#x27;t the focus that (what seems like) most people take.<p>The DOM isn&#x27;t (that) slow; it&#x27;s all the crap we do to it that makes it slow.<p>React&#x27;s strongest selling point is its ergonomics: It frees the developer from having to write huge swaths of code that they otherwise would be with most previous libraries&#x2F;frameworks.<p>It achieves that with its immediate mode rendering: you no longer have to reason about how to transition the DOM from one state to another (in nearly all cases).
评论 #10987572 未加载
评论 #10990781 未加载
jonduboisover 9 years ago
Every point made in this article also applies to Google&#x27;s Polymer framework. The stuff about having handlers which trigger when an element is attached or detached, the point about updating only the sections of the DOM which changed, the speed, the data binding magic, everything... It all applies to Polymer as well. Except that Polymer was around long before React. Also Polymer doesn&#x27;t require any special tooling and no build steps necessary.<p>The point about attachment&#x2F;detachment handlers also applies to Angular directives by the way. So it is extremely misleading to claim that React is revolutionary because of this. I think Angular was revolutionary, the only real new thing that React brings to the table is that you can have your HTML inline with your code - Some people think that this is the &quot;secret sauce&quot; which makes react so modular and makes its components so well encapsulated, but it is not - Polymer achieves the same level of encapsulation without combining logic with markup.<p>React is just one of multiple good alternatives which may be better in some scenarios and worse in others.<p>Developers are being too idealistic about this. I think the web would be a better place for developers if we were more aware of the irrational nature of hype.<p>I dont have anything against React but I don&#x27;t like hype. Hype is just excitement in the absense of reasoning. It&#x27;s the result of good marketing and nothing more.
评论 #11002638 未加载
EGregover 9 years ago
<i>React has, ironically, allowed us to once again think about writing web applications as a series of pages rather than a monolithic blob of JavaScript code. It&#x27;s no wonder that developers have become so engaged with React and React Router: it&#x27;s the same mental model as traditional server-only applications. A page is rendered, some changes are requested, then a page is rendered with those changes. The only difference is that this can all happen client-side.</i><p>Our framework does this, without virtual DOM. You build apps by placing reusable components on pages. The pages honor existing web conventions -- so everything works like on the web. But then the framework manages HTML5 history for you, and even swaps javascript&#x2F;stylesheets in and out as you load pages. It loads the code for pages and components on demand, as you navigate the app, and doesn&#x27;t need a monolithic js and css file (although you could have one). Part of sticking to web standards is you can do things like caching on CDN, or even support caching files inside a PhoneGap bundle, so they load instantly on a &quot;native app&quot;, which you can make.<p><a href="http:&#x2F;&#x2F;qbix.com&#x2F;platform&#x2F;guide&#x2F;pages" rel="nofollow">http:&#x2F;&#x2F;qbix.com&#x2F;platform&#x2F;guide&#x2F;pages</a><p>All this does not require a virtual DOM. React and Mithril are great for virtual DOM but you don&#x27;t NEED it. In fact, the fastest approach to components re-rendering themselves is:<p>1) Have the constructor insert the HTML elements, eg by rendering a template, and <i>store references</i> inside the component to the elements it might want to update.<p>2) When some of the component&#x27;s state changes, simply requestAnimationFrame and make a batched update, using the same convention as react&#x27;s &quot;render&quot; method. Only the components whose state changed will update. That&#x27;s what Angular does: dirty checks the state instead of the DOM.<p>3) Traversing parents and children should be done via the component object tree, not the DOM.<p>And voila. You have the speed you need, where you need it. The main challenges are other things, like registering&#x2F;unregistering events, activating&#x2F;removing components while navigating pages, caching, retaining data until you don&#x27;t need it anymore etc. And for that you need a framework.
andrewingramover 9 years ago
I don&#x27;t think performance concerns really got people to avoid DOM manipulation in practice, but it did mean that more thoughtful developers had to jump through a large number of hoops to make things perform well.
评论 #10987598 未加载