r/javascript • • Jun 01 '15

Is ReactJS faster than AngularJS ?

http://blog.500tech.com/is-reactjs-fast/
22 Upvotes

47 comments sorted by

View all comments

29

u/cgaudreau senior HTML9 engineer Jun 01 '15

I feel like this is desperate grasping at straws. It is theoretically possible to make Angular nearly as fast or faster than React is out-of-the-box, but the pain involved in doing so is massive. Yes, it's easy with little 5-line code snippets, but try doing so in a reasonably-sized application. It's hell.

React makes it easy to be fast by default. You generally don't even have to think about performance, and if you do have to, it is very easy to grasp. You don't need to frantically search extremely poor documentation.

How to optimize a React application: Implement shouldComponentUpdate. Or if you want performance by default, just use immutable data structures.

How to optimize an Angular application: Keep your scopes small. Keep it under 2000 watchers. Pollute your code with one-way bindings. Still no improvement? Oh, you need to do one-way binding here, too, in some obscure way. Don't watch functions. Don't watch objects. No $broadcast or $emit. Don't have big arrays. Should I use $digest or $apply? Why is this watcher causing the digest loop to take 500 ms to execute? No filtering or sorting unless you want to go mad. Did I mention using filters causes $index to be invalidated? How the hell do I even find out what's performing poorly?

I don't even know if any of that is correct anymore. It's too painful to remember. I want to be liberated and forget the literal hell that is Angular 1.x.

13

u/jhallister Jun 01 '15

It will never cease to amaze me how quickly people turn from in-love to "this is literal hell". I remember when I first started working with AngularJS and everyone was swooning and now a new shiny toy is out and the hatred is extraordinary.

Yes, it's easy with little 5-line code snippets, but try doing so in a reasonably-sized application

I've been on teams that have built AngularJS applications of enormous size. It isn't hell, at least, if you actually spend the time to understand how to properly use Angular. It's certainly not always straight-forward, but hell != difficult.

How to optimize a React application: Implement shouldComponentUpdate. Or if you want performance by default, just use immutable data structures.

If you honestly believe a large team developing a large application can shove immutable.js in it and get production-ready performance than you clearly haven't programmed large applications.

Furthermore, why are you comparing a view-manager (React) an entire front-end framework (AngularJS)? No $broadcast or $emit? Events have nothing to do with performance, but they are the antithesis of good Angular design. You should do $digest if you need watchers to fire in the current scope only, you should use $apply() when you want the root scope (all watchers) to $digest().

The one and only real problem with Angular was always the same: the docs were really, really bad. As a result a lot of people simply couldn't learn the framework, or at the very least couldn't learn to use it well. Some couldn't because learning without good documentation is tedious. That's a very fair argument.

The downside, however, is that it's now vogue to talk about how horrible AngularJS is and list off a bunch of grievances, the majority of which show that the person really didn't learn Angular, for whatever reason.

React is a great view manager. It has a host of problems as well, and more of those problems will become apparent when the framework ages, much as they did with Angular. And undoubtedly, we will eventually come full circle and have people whining about how horrible React is compared to JesusFramework 1.0.

Honestly the real reason, webdevs just like to whine about something.

END BOOK/RANT

3

u/siegfryd Jun 02 '15

Furthermore, why are you comparing a view-manager (React) an entire front-end framework (AngularJS)?

Because they're comparing Angular's view management compared to React? Nobody is going to pick Angular just for modules, dependency injection or the utility services it has.

2

u/jhallister Jun 02 '15

The article compared Angular's view management compared to React as evidence of why React is better. But the comparison is unfair. The article didn't compare $digest() it simply showed that the React demos that prove how much faster it is are in fact, bad demos.