Hacker News new | ask | show | jobs
by Bahamut 3156 days ago
Angular 2+ is much better than 1 - it fixes pretty much all of the warts with 1. On the flip side, there are some tradeoffs, some that is not quite Angular’s fault, although they’re tradeoffs chosen by the Angular team in designing the framework.

Angular doubles down on the component-based model it tried to emphasize in Angular 1. It also is very performant. The main router is much better than Angular 1’s.

I haven’t used Angular in the past 5-6 months though - in my current role, we decided on React, and have been satisfied with it for the most part, although some things have been more painful than if we were to use Angular (testing being the big one), but also some things are simpler too. There’s tradeoffs with whatever library one goes with, but as a whole, Angular is still a very strong choice IMO.

2 comments

That's surprising to me! My main complaints of Angular 2+ are around testing, but I've had nothing but love for React testing (enzyme, chai, karma)

EDIT: whoops, mistyped. We don't use karma anymore in our React testing stack. It's mocha now.

My gripe with testing in React has a lot to do with testing in JS in general - it avoids the elephant in the room of how to mock dependencies (whether it be functions, classes, etc.), and control various scenarios so you appropriately unit test business logic. One can impose a solution by convention with React, whether it be creating/using a DI mechanism, creating functions that one can pass in dependencies to that returns the desired function, or other numerous ways. Or one can choose to avoid creating a solution and decide not to directly test those scenarios, but then that just leads to more expensive, fragile, and complicated scenarios where one loses the advantage of the fast & tight feedback cycle a unit test gives you.

Angular’s solution of a robust DI mechanism is a little on the heavy side, and the test execution perf is worse than Angular 1’s in general, but it is almost certainly the most powerful test helper situation available for testing frontend JS chrrently.

Note that testing serverside JS doesn’t suffer as much, since there are libraries for making use of the require cache for mocking such as testdouble.

Chai and karma aren't specific to react. I remember using them with angular 1.x back in the day.
Aye, I didn't mean to imply that, I was listing my React testing stack :)

Hah, looking now, I realize I mistyped. We use mocha, not karma. Was conflating things

I thought Karma was specific to Angular in fact!
Enzyme and Jest (for React) are pretty awesome. I haven't seen UI testing that good elsewhere...not to mention Storybooks which are great for documentation and manual review. Snapshots, auto mocking, etc...you can't beat React's tooling.