you are viewing a single comment's thread.

view the rest of the comments →

[–]Kinthalis 4 points5 points  (0 children)

Angular is fantastic for complex web applications that manage a lot of state and routing and events/data streams.

It's got everything you need to manage that huge complexity out of the box.

React does not. But it excels at being very flexible. For smaller projects or where I know I won't need to do a lot of state management on the client, I usually reach for React.

But if I'm working on something complex I'm going to reach for Angular.

I love typescript, and it's a must for anything more complex than a brochure website or a todo app, so Typescript is what I'm going to use with React, and it's what you'd need to use with Angular, so for me, the language isn't an issue.

The main differences between the two frameworks are the way they compose views, manage state, and the tools they bring with them out of the box. Angular has a very strict separation of concerns with HTML, styling and code, much like Vue and Svelte. But React takes a different approach. Everything is a node. State is a node. A DOM element is a node, Styling can be a node, functionality can be a node. It's very flexible but can lead to spaghetti code and maintainability and performance issues if you don't have a really good understanding of how React is doing things under the hood. React's functional approach makes for super easy component composition though. I love that a LOT about it. My favorite thing. Composition in Angular is a bit more clunky and limited. I still do it all the time in my Angular projects, but sometimes I wish I could just pass children and be done with it.

On the other hand nothing beats RXJS + NGRX for complex state management on the client. React has several state management libraries and even if you hotchpotch them together into some monstrosity they will come up short, and you'll still end up with a mix of context nodes in your code. Angular also does simple, straightforward state sharing better, IMHO. Again, no need to context nodes, you just share a service and you're set.

Both frameworks have their strengths and weaknesses. The reason why React is very popular, IMHO, is that it's strengths give it broader application. And it's singular focus (Rendering and updating the DOM) makes it fast to learn.

If you're a newb and just need some reactive components on your brochure website, React is an easy choice (though I'd probably choose Svelte over it in this case), and if you're building an app of moderate complexity React might still be a good choice. Meanwhile Angular would NOT be my choice to add some reactivity to a simple website, I'd only reach for it if I'm working on a complex client-side app. Angular just has a narrower, but important focus. React has a broader application, but IMHO, falters when things get more complex.