Hacker News new | ask | show | jobs
by bpye 2572 days ago
I've been using Angular for a few months now and it's mostly been a good experience. We've been using Angular 7.

My biggest gripe, and this might just be my inexperience, is fighting the change detector to try and ensure reasonable performance when displaying a large number of elements. There are certainly mechanisms to do this but it does seem to take some work.

4 comments

Switch to OnPush, use async pipes and immutable data structures. Add to that some of the virtualization components that ship with @angular/cdk and you're pretty golden most of the time.
You should be using OnPush everywhere, then your struggle will change to only getting changes detected in certain scenarios. Still a pain sometimes but not as bad as the Default change detection strategy.
FWIW, the Angular team is aware that this is a pain point. There were several talks at NG-Conf a few weeks ago that referenced replacing or removing zone.js-powered change detection for increased performance and/or smaller build sizes. They're trying to avoid another Angular 2 situation though, so it may take a while for a backwards compatible solution to surface as the default.
This is precisely what I don't like about Angular. That there is all this stuff. And I have to care about what it is doing under the hood (and this is complicated and not especially well documented).

In React if I have performance issues, then it's pretty easy to work out what's causing them.

You can largely ignore what Angular is doing under the hood, tbh. If you're having performance issues, the answer is often related to change detection (aka, Zone.js).
> If you're having performance issues, the answer is often related to change detection (aka, Zone.js).

This is part of Angular really. At least it's not optional to use it. Change detection issues are not fun to debug!

> At least it's not optional to use it.

Zone.js is optional, although it is on by default. It's considered best practice to remove it when building standalone components with Angular Elements.

what's your use case to display a large number of elements in the same page? Curious.
like lists with thousands of elements? OnPush change detection and virtual scrolling - https://material.angular.io/cdk/scrolling/overview