r/javascript • • Nov 05 '14

AngularJS: The bad parts

http://larseidnes.com/2014/11/05/angularjs-the-bad-parts/
87 Upvotes

88 comments sorted by

View all comments

-3

u/lord2800 Nov 05 '14

He's missed part of the point. Short of very bad design, this is always resolvable by reading the source code:

<input type="text" ng-model="obj.prop" />
<div ng-if="true">
    <input type="text" ng-model="obj.prop" />
</div>

See the . inside that model name? That means unless someone does really dumb things with the dependency injector, the two models will always refer to the same thing. There is no magic here--this is basic JavaScript prototypal inheritance. You have this exact same "problem" (I use the term loosely) whenever you read JavaScript code.

His rant about the "magic" dependency injector is noted, well received, and being fixed. So it's a non-issue.

His point about the digest loop, is just plain stupid. How else would you build it? Because that's literally what every UI framework does currently--including the browser his site is being rendered on. If he has some magic means of changing that, then please, by all means, enlighten the rest of us. That being said, the "magic number" of 2000 was never a magic number, and it was a misinterpretation, and it's also just plain wrong. And it's not relevant to today's Angular, which includes one-time bindings. And more importantly, it won't be necessary in the future with Object.observe.

His points about the documentation describing things strangely has been an active focus of fixing. But he's missed the point, once again, on some of this: people redefine terms all the time. It's part of being a living language.

And for his final point, he's once again missed the fact that this is being fixed. I'll be the first to admit that the fix seems a little clunky (requiring support for something that doesn't exist and won't exist in ES6 at this point), but frankly doing token-based injection as a concept is much better than the existing argument-based (ultimately string-based) injection.

16

u/maktouch Nov 05 '14

See the . inside that model name? That means unless someone does really dumb things with the dependency injector, the two models will always refer to the same thing.

The point was:

If you type into the first input field first, the two inputs will share the same model. If you type into the second one first, they will have distinct models.

^ That's a wtf moment (and the point). It's explained right here: http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs/14049482#14049482

Like the author of the stackoverflow comment says, "It doesn't work the way most people expect it should work."

Because that's literally what every UI framework does currently

That's not really true.. React, Vue, Ractive are the ones that comes to mind that doesn't use a digest loop. I'm sure there's plenty other..

[...] people redefine terms all the time. It's part of being a living language.

But that's the problem, Angular is not a language, it's a framework.

But yeah, all those things are "getting" fixed... in 2.0? When is that going to be released? Will it be easy to upgrade?

I've think you missed the point of this article. At the current state of angular, the author doesn't think Angular is a good framework, and I agree with him. "Being fixed" is not a pros, it's a cons until it's fixed, released and tested.

-7

u/lord2800 Nov 05 '14

That's a wtf moment (and the point)

And is utterly and completely wrong. The . is what makes that not the case--it forces the prototype lookup to access the expected variable, rather than creating the new one. That's why the author is wrong.

That's not really true.. React, Vue, Ractive are the ones that comes to mind that doesn't use a digest loop. I'm sure there's plenty other..

None of those are UI frameworks. And they do, in fact, all do the same thing that Angular will be doing, which is iterating over the things that are known to have changed and then notifying subscribers.

But that's the problem, Angular is not a language, it's a framework.

A framework written by people. People are the ones redefining the things, not the framework.

But yeah, all those things are "getting" fixed... in 2.0? When is that going to be released? Will it be easy to upgrade?

Some of them earlier, some of them later. Things are still in flux for exactly these reasons.

At the current state of angular, the author doesn't think Angular is a good framework

And a good reviewer/journalist/whatever he wants to call himself would have called out the things that are in flux. But he did none of that.

All of this being said, I'm a fan of stripping apart Angular (which they're already doing) and just using Web Components for the frontend UI (which I can do by not including the templating engine). Angular has drastically shifted my thinking on managing UI componentization, and Web Components has only reinforced that.

-6

u/lord2800 Nov 05 '14

Just to prove a point, here's point #1 thoroughly debunked: http://plnkr.co/edit/fR3CJCIaXE8mf8CvQGHL?p=preview

8

u/maktouch Nov 05 '14

How is that debunked? It does exactly what the author said it do.

  1. When you edit the first input, the second input get modified, as expected.

  2. Refresh.

  3. When you edit the second input, the first input doesn't get modified.

It's a problem with 2-way binding. Since Angular uses 2-way binding, that's a problem.

1

u/ganarajpr Nov 06 '14

Wrong attribution. Its not a problem with 2-way binding. Its a problem with prototypical inheritance.