10 ms·
Maybe because React is small (API surface) and does (or is felt to do) “one thing”. It is easy to wrap your head around it, even without fully understanding, sa
by fuzzy2 7y ago
Maybe because React is small (API surface) and does (or is felt to do) “one thing”. It is easy to wrap your head around it, even without fully understanding, say, the Virtual DOM diffing. Angular is very different in that regard.
I recently had to read up on how Angular applies changes to the DOM. It was extremely difficult to get this information at all.
For me, React with TypeScript is king. It trumps Angular in three IMHO very critical points:
* Typed “templates” (a tremendous help with IntelliSense, too)
* No change detection magic (I firmly believe Zone.js is insane)
* Build time
- buu700 7y ago* Angular templates are typed, but until version 9 (coming out in a couple weeks, but I've been using the RCs and they've been fine), any variable created in the template itself was defined as `any`, creating gaps in the compiler's coverage. A vscode plugin provides IntelliSense. * Agreed, this is an awful default and I don't understand why the Angular team hasn't already deprecated it. I suppose a slightly simpler "Hello World" makes Angular look a bit more approachable, but it just encourages accumulating unnecessary tech debt. The proper way to use Angular is to disable the magic (`OnPush` change detection) and use observables. * Prod builds take a while and use a lot of memory, but local development is fine. (I haven't observed that prod builds are necessarily "slow" relative to what they accomplish.) I like both Angular and React, but generally prefer Angular. The structure and universal consistency imposed by the framework and CLI are convenient (particularly when moving between projects or adding devs to an existing project), and the limitations imposed by Angular-HTML vs JS(X) are great for readability.
- tashoecraft 7y agoI think angular with zones will slowly start to fade away as the community moves more towards onPush components, with components hooks to trigger change detection. There is an ngrx proposal for a component that would handle this all nicely, but it's still only a proposal.
- fuzzy2 7y agoOn templates: Weeeell, no(-ish). Angular templates are text. They are checked during AOT compilation or otherwise at runtime (were most type information is gone already). And maybe at some other point I don’t know about. The Angular Language Service (which came very late) is a lot of help, if doesn’t fail to pick up component members yet again. I’m not sure whether it knows about types either. It also has problems with some complex use cases: for example, we have a derived `CdkTable` attribute, yet it doesn’t pick up its input properties. tl;dr: I don’t like text templates! I really like React “templates”! :D There’s also a minor annoyance: I’m not very fond of having the components as elements in the DOM. At least with modern browsers they behave predictably! On change detection: While `OnPush` is required for any sane application, you really need to fully disable Zone.js unless you want your application to re-render pointlessly. That could cause problems with third-party components I guess...? Either way, it’s really not as straightforward as it should be.
- buu700 7y agoIn what sense do you mean that Angular templates (with the language service) more "text" than other programming languages? Everything definitely has a type, and I'm not having any issues with syntax highlighting, mousing over things to see what they are, or peek / go to definition. There are a couple hiccups[1], but those are just tooling issues. The template is ultimately compiled to TypeScript, which is type checked as one would expect. In my mind Angular-HTML is the same type of thing as TSX/JSX, except with the problem of being more unique / further removed from the target language, so not benefiting as much from preexisting tooling. It's actually a minor annoyance for me right now that my existing code isn't yet compatible with the strictest compilation setting[2] because it was developed against the older, more lax compiler that littered its emitted TS with `any`s. If you're having trouble with the complex use cases (which I've definitely run into as well), Angular 9 / Ivy will be a welcome upgrade. (And totally agreed re: Zone; it needs to die in a fire.) --- 1: 1) "Find All References" isn't working for me (I'll file a bug report if there isn't one already), and 2) I have to peek definition to see what something's type is; as-is it just says "(property)". 2: https://next.angular.io/guide/template-typecheck#strict-mode https://next.angular.io/guide/template-typecheck#strict-mode