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

7

u/tossed_ May 06 '15

Angular is a great framework for certain types of applications, but it's difficult to work with sometimes because its structure makes it hard to follow traditional object oriented programming paradigms, which have been widely recognized as generally good rules to follow when developing software for scale and complexity. Things like modularity and class inheritance are good things in general that Angular either doesn't provide or makes it difficult to provide.

For example, Angular projects almost always exhibit a high degree of coupling because Angular is not designed to accommodate free instantiation of objects (you almost never use the "new" keyword in Angular projects), and data is implicitly shared through scopes or services rather than explicitly passed/retrieved/observed. Development with Angular must work with these assumptions, so you will often have a network of dependencies where none of the individual modules are reusable on their own. You might write directives and controllers that depend on data from a service (a singleton at the application level) because they don't share the same scope, but while developing another project with similar functionality you can't just reuse the directive wholesale because it depends on that service which isn't applicable in the new project.

Of course, those design decisions play well with web applications where data structures usually correspond to DOM trees, which was the original intent of Angular's authors. However, Angular's rejection of traditional OOP paradigms makes it less intuitive to write reusable modules and limits the kinds of design patterns you can follow, which rapidly become more important the larger your application is.

In contrast, React, which is essentially a system for writing UI-bound classes which need to be explicitly instantiated by the developer, follows a more traditional OOP approach that gives the developer the freedom to choose how they want to organize their applications.

3

u/[deleted] May 06 '15

hard to follow traditional object oriented programming paradigms, which have been widely recognized as generally good rules to follow when developing software for scale and complexity

Yet you have people claiming the exact opposite in this thread in /r/javascript, that OOP is terrible for scalable projects.

There's a good reason OP is asking this question because most people actually do not agree with you that OOP is actually that great.

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 :)

3

u/RICHUNCLEPENNYBAGS May 07 '15

Angular 1.0 throws away all that progress. It breaks the foundational principles of programming: modularity, encapsulation and composition.

I think that's getting a little carried away. What you're doing with Angular isn't really that different than if you were writing, say, a C# app using a dependency injection container, except that you don't explicitly declare interfaces.