Hacker News new | ask | show | jobs
by nemanja 3997 days ago
This smells like a shill piece by a Google developer advocate [1] with a horse in the race [2].

The key benefit of React is an extremely low cognitive load. There are only three simple concepts to grok (props, state and lifecycle) to get productive. The code is very easy to reason about (components are essentially pure functions of props and state) and debugging is much simpler than with vanilla JS or jQuery on a project of any meaningful size.

With respect to performance, React shines when it comes to DOM mutations (e.g. removing a div from DOM, creating a new div, inserting new div into the DOM) which is what you generally encounter with the real-world load. Here is a demo illustrating such load [3]. Benchmark offered by OP is amazingly contrived (actually it feels designed to show React in a bad light and lack of full source code is very telling). I struggle to think of a real-world scenario of append-only page with 1000+ images in the DOM, there is simply no valid reason to do that. React in turn makes it really easy and fast to implement infinite scrolling (similar to UITableView) and there are a couple of good open source components that address that.

[1] See the bottom of https://aerotwist.com/

[2] https://aerotwist.com/blog/polymer-for-the-performance-obses...

[3] https://www.youtube.com/watch?v=1OeXsL5mr4g

3 comments

Yeah. I mean...

First off, the attraction of React, to me, is mostly based on being able to write maintainable, testable, reusable, easy to reason about code when working on large, complex webapps. Yeah, React has relatively high performance—at least when compared to a sluggish framework like Angular when writing those large apps, but that's not even the core selling point (as far as I'm concerned). But okay, part of the attraction of React could be summed up as "better performance than Angular on complex applications", and I guess a benchmark proving (or disproving) that would be nice to have.

That's not what we got. Instead, this guy tested the raw performance of some very simple code compared the sort of vanilla code you'd never ever ever write in the sort of app that React (or Angular) is actually designed to help with. So...yes, React is slower than vanilla JS at stuff that vanilla JS is faster at. Shocking.

I'm struggling to think of a less meaningful way to do the analysis.

Said every developer who's never had to "just speed up" an application written with a framework that makes development/debugging easy, but has fundamental performance issues that cannot be overcome without a significant overhaul.
Felt the same to me. But I did learn of shouldComponentUpdate while reading the comments here, which for the author's scenario would seem to reduce computation time when using React exponentially. It's nice that React gives you an "advanced" scenario if you so need it for your uber-update-all-the-elements website.
Here is a really good talk on React performance that may also be helpful - https://www.youtube.com/watch?v=KYzlpRvWZ6c
Shill, agreed. Surprised to see that this Google developer advocate leaves Angular out of the test and focuses solely on React.