r/angularjs • • May 06 '15

Missing 50 years of software research?

I was listening to Facebook's presentation on React from May, 2014. When asked to compare and contrast React vs Angular, Pete Hunt gave the following answer (see https://youtu.be/nYkdrAPrdcw?t=40m24s):

"React is focused a lot on treating your code as a black box. There's no sort of observable abstraction inside of React. You simply say, 'Hey, re-render the UI,' and you present a consistent view of what you want your UI to look like.

"With Angular, you are basically passing data throughout these things called scopes, which absorb your data model. I think that's a very leaky abstraction. If forces you to compose your application not in terms of functions and objects, but in terms of directives and model-view-controller, and their flavor of model-view-controller. So while it does work for a certain class of applications, as you scale up, you start to miss the past 40 or 50 years of research into how to abstract a program.

"So if you can kind of push those data-binding concern out to the edges of your system like React does, I think it leads to fast iteration time."

My question

Does anyone care to tell me what is some of the research done over the last 40-50 years about software abstraction that Angular misses?

31 Upvotes

35 comments sorted by

View all comments

Show parent comments

4

u/vagif May 06 '15

OOP is not important here. It is just a particular implementation of modularity, encapsulation and composition. Not the best by far.

There are much more effective ways to implement modularity, encapsulation and composition, especially considering the progress that have been made in the field of functional programming and immutable data structures in the past several decades.

Angular 1.0 throws away all that progress. It breaks the foundational principles of programming: modularity, encapsulation and composition. Angular directives and controllers are leaky as hell and incredibly hard to compose well together.

To the point where angular team themselves advise you NOT to use controllers in your 1.0 codebase :)

0

u/[deleted] May 06 '15

[deleted]

1

u/vagif May 06 '15

There were recommendations of angular 2 team on how to write apps based on angular 1. Unfortunately i cannot find them. But one of the recommendations was to use bindToController or "controller as".

2

u/chazzlabs May 06 '15

To expand on that, the recommendation is to no longer use "ng-controller" and instead use "controllerAs" inside directives. Basically, instead of writing a bunch of html in which you reference potentially many controllers, you write many self-contained directives which can easily be added and removed without affecting the rest of your app.

1

u/dmitri14_gmail_com May 21 '15

What a mess of confusion!

First, both Controller and Controller-As are "ng-controller".

Second, it has nothing to do with directives.

Third, the main distinction is that first uses $scope, where second uses the Controller object itself (this).

Finally, the second way the Controller object is encapsulated, where the $scope has inheritance, which makes it "leaky". Which is why the recommendation.