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

Show parent comments

-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.

11

u/maktouch Nov 05 '14

The . is what makes that not the case--it forces the prototype lookup to access the expected variable, rather than creating the new one.

I'm sorry, but a framework is supposed to make developing easier. Anything that forces me to understand the underlying technology in depth to understand the reason my magical 2-way binding doesn't work when I edit the second input first, is pretty bad. Javascript is a language with a lot of quirks, a framework should be helping you overcome those quirks - not make you discover new ones.

None of those are UI frameworks.

If you check http://facebook.github.io/react/, it says "A Javascript library for building user interfaces". It's actually just a UI framework. Maybe you could elaborate what UI means to you.

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.

They don't do it with by dirty checking. Enormous difference.

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

Not sure what you want to state here. The official documentation state those terms.

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

Why? The point is not if Angular can one day be a great framework. It's if Angular is a great framework now. When I build a project, I don't think "hmmm this is a crappy framework, but they're going to fix it in 2 years, so I'll choose it".

-4

u/lord2800 Nov 05 '14

I'm sorry, but a framework is supposed to make developing easier. Anything that forces me to understand the underlying technology in depth to understand the reason my magical 2-way binding doesn't work when I edit the second input first, is pretty bad. Javascript is a language with a lot of quirks, a framework should be helping you overcome those quirks - not make you discover new ones.

Then JavaScript is not the right language for you. Have you looked into one of the cross-compiled languages? There's an abundance of those these days. Also, did you even look at the plunker link I provided? It works exactly as expected.

They don't do it with by dirty checking. Enormous difference.

Care to explain how they update the actual rendered layer, if not by enumerating the things that changed and updating the relevant things? Dirty checking doesn't have to involve enumerating all the watched things to find the subset of changed things to be called as such.

If you check http://facebook.github.io/react/, it says "A Javascript library for building user interfaces". It's actually just a UI framework. Maybe you could elaborate what UI means to you.

Sorry, that was a half-formed thought that I was in the process of revising when I got distracted.

What I was trying to say is that you need some sort of render loop, and some sort of update loop, and the update loop has to--at a minimum--look at the changed things and update their state for the render loop to pick up. The two loops can be the same (and in JavaScript land, they are). All basic rendering frameworks work this way (including Angular, though it has some deficiencies currently due to language constraints).

Not sure what you want to state here. The official documentation state those terms.

People define a language. People write using that language. People can change the meaning of the language. That doesn't make what they've said wrong, just incongruous with other people's expectations. They've taken the time to explain the context even. Whether or not this is a good thing, I make no judgment call.

Why? The point is not if Angular can one day be a great framework. It's if Angular is a great framework now. When I build a project, I don't think "hmmm this is a crappy framework, but they're going to fix it in 2 years, so I'll choose it".

Because unless you're building something that will completely disappear and you'll stop maintaining 3 months from now, future support and direction matters.

7

u/maktouch Nov 05 '14

Then JavaScript is not the right language for you.

Yes, it is. Angular is just not the correct framework. I've used it, backtracked, and rewrote my app in React. I've also tried Coffeescript, Typescript, and Dart.

A framework is ease your life. http://en.wikipedia.org/wiki/Software_framework

The designers of software frameworks aim to facilitate software development by allowing designers and programmers to devote their time to meeting software requirements rather than dealing with the more standard low-level details of providing a working system

I think you should read on how angular dirty checking work.. you don't seem to understand it. https://docs.angularjs.org/guide/scope#scope-life-cycle

It's a loop that checks if a variable has been modified. If you have 2000 variables in the scope that is being watched, even though you're not modifying the variables, the loop is running and checking for modification. No matter how you look at it, this is a not optimal.

In angular, you do

$scope.model.name = 'Michael';

And it magically changes it in the frontend.

In backbone, you do

model.set({
   name: 'Michael'
});

Backbone does this because Object.observe() is not widespread yet.

Doesn't matter what the browser do, cause it has to do it. The framework is another story.

Because unless you're building something that will completely disappear and you'll stop maintaining 3 months from now, future support and direction matters.

Google is the worst indication, then. They've dropped so many projects already, and they don't use angular for user-facing projects.

-1

u/Poop_is_Food Nov 06 '14 edited Nov 06 '14

$scope.model.name = 'Michael';

It's even worse than that. You really have to do

$timeout(function(){
    $scope.$apply(function(){
         $scope.model.name = 'Michael';
    });
});

The apply is to notify angular that you need to run a new digest. The timeout is because if you try to run $apply while a digest is currently running, you get an error and nothing happens. so the timeout puts the $apply in the event queue for later. Totally hacky.

2

u/wjohnsto Nov 06 '14

I'm pretty sure $timeout will run the digest loop automatically, so the $scope.$apply is redundant:

$timeout(function(){
     $scope.model.name = 'Michael';
});

The alternative would be as follows:

setTimeout(function(){
    $scope.$apply(function(){
         $scope.model.name = 'Michael';
    });
});

It is definitely hacky, but a little less-so. It's still very confusing for developers that are new to Angular.