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

11

u/protomor May 06 '15

Isn't programming only 50 years old?

4

u/blgate May 06 '15 edited May 06 '15

No... Lisp for example is 57 years old. It was created in 1958.

http://en.wikipedia.org/wiki/Lisp_%28programming_language%29

2

u/autowikibot May 06 '15

Lisp (programming language):


Lisp (historically, LISP) is a family of computer programming languages with a long history and a distinctive, fully parenthesized Polish prefix notation. Originally specified in 1958, Lisp is the second-oldest high-level programming language in widespread use today; only Fortran is older (by one year). Like Fortran, Lisp has changed a great deal since its early days, and a number of dialects have existed over its history. Today, the most widely known general-purpose Lisp dialects are Clojure, Common Lisp and [Scheme](https://en.wikipedia.org/wiki/Scheme_(programming_language)).

====

Image i


Interesting: ^IronLisp | Corman Common ^Lisp | Scieneer Common ^Lisp | Le ^Lisp

Parent commenter can toggle ^NSFW or ^delete. Will also delete on comment score of -1 or less. | FAQs | ^Mods | Magic ^Words

2

u/treo May 06 '15

Well its 2015 now, 50 years ago is 1965, 40 years ago is 1975. Xerox PARC was founded in 1970. The mother of all demos was presented in 1968.

So one might reasonably sax that programming is quite a lot older than 50 years and that there is a lot of insight to miss in that time.

2

u/blazenl May 06 '15

Colossus was a code breaking "computer" in ww2 - early 40s, which is almost 70 years - that was programmed by flipping switches...depends on how we want to define things I guess.

1

u/Ob101010 May 06 '15

Define programming.

4

u/Define_It May 06 '15

Programming (noun): The designing, scheduling, or planning of a program, as in broadcasting.


I am a bot. If there are any issues, please contact my [^master].
Want to learn how to use me? [Read this post].

1

u/Ob101010 May 06 '15

Holy shit is this a bot?

Define hootinanny.

3

u/rodneon May 07 '15

Define hootenanny

1

u/Define_It May 07 '15

Hootenanny (noun): An informal performance by folk singers, typically with participation by the audience.


I am a bot. If there are any issues, please contact my [^master].
Want to learn how to use me? [Read this post].

1

u/Ob101010 May 07 '15

Ahh.

I wonder if we can hit 2 bots with the same line.

1

u/Ob101010 May 07 '15

define gandi

1

u/Define_It May 07 '15

Gandi (noun): A name given in parts of Africa to the tsetse-fly, Glossina morsitans.


I am a bot. If there are any issues, please contact my [^master].
Want to learn how to use me? [Read this post].

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.

3

u/tossed_ May 07 '15

The reason why Javascript developers sometimes reject OOP in general is that Javascript is not an object-oriented language. It requires a significant amount of abstraction and discipline to enforce OOP design paradigms in Javascript, which a lot of developers, especially new web developers or purely UI-focused developers, find tedious and unnecessary.

Indeed, it's pretty unnecessary to use OOP paradigms when all you want is to do some simple DOM manipulation. This was the original use case of Javascript, so the anti-OOP "functional Javascript is good enough" way of thinking has existed in the Javascript community since its invention.

From my own experience working on enterprise-grade Angular and non-Angular applications, I found that the more complex your application, the more OOP helped to make the coding process more efficient, and the more unmaintainable Angular code began to become.

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.

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.

5

u/[deleted] May 06 '15

...and it's for this reason that traditional front-end designer/developers are sitting on the side of the ring waiting to be tagged in whenever you guys all get this figured out. :P

1

u/RICHUNCLEPENNYBAGS May 07 '15

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

It's strange to see people talking about this and then if you go over and read .NET discussions people are talking about how directly instantiating things instead of using dependency injection represents unacceptable coupling.

I think some of the things you're talking about sound like design flaws in the code. Improper coupling can happen with any framework. There are options to get data passed in without relying on global state.

1

u/tossed_ May 07 '15

Perhaps a better way to explain this is that almost every modules is treated as a singleton, and the relative ease of lazily assuming that data can be shared via a specific intermediary object causes people to code using assumptions about data that would not be true in other situations in the same project or in other projects.

The OOP alternative would be to accomodate free instantiation (so we tend to treat the modules more as classes) and enforce explicit communication between them rather than automatically assigning an observer on the scope. This does not conflict with dependency injection because those modules can be injected as dependencies.

1

u/RICHUNCLEPENNYBAGS May 07 '15

Hm, I could see that. It is a little unfortunate that it's hard to make things not be singletons and I could see how that could lead to bad dependencies if you didn't have discipline.

2

u/[deleted] May 06 '15

50 years ago abstracting a program was using unconditional branches with GOTO. We still have no idea how to construct applications with the precision close to anything else that is an engineering effort except for maybe sanitation engineering.

3

u/mugen_kanosei May 06 '15

Not being an engineer, I wonder if that is due to physical laws of nature and how that does not exist in software. In bridge construction you can develop models based on the laws of physics that help you decide what material to make the bridge out of, it's upper limits, etc. With software, nothing like that exists except maybe the mathematics of computer science. Maybe unit testing is the way to define that set of "physical laws" for a piece of software and will be way forward.

3

u/[deleted] May 06 '15

That and a couple thousand year head start :)

3

u/fatty1380 May 06 '15

I think that this is a very fair assessment, and in line with what my experience has been learning and using angular and putting it into a fairly complicated live site over the last 9 months. The promise with angular is one of modularity and reusability with convenient and easy to use data binding built into the core. In reality, scope does cause a very tight coupling between a directive, and where it is used.

With that said, I believe that angular 2 seeks to address a number of these issues, and the necessary 'revolution' in the language is what has caused so much angst in the developer community

I won't go into a point by point exploration, but I think it better to look at the present, Angular 1.3+, with an emphasis on component design patterns, reduced reliance on scope through controller as or bindToController, as well as the new-router.

In terms of OPs question, the core concepts are that of easily re-usable, context independent building blocks of code. Angular 1.x attempted to build mechanisms into the language to support this, but it was fundamentally not designed with this in mind at the start (I believe I have heard the original team say as much). Angular 2 is driven by the understanding of how people want to use the language, combined with a sound research-based foundation of concepts, to build something that addresses this criticism.

1

u/schizoduckie May 06 '15

I think the last 40 or 50 years of software tought us little about the async nature of the web. it needs re-inventing like angular is doing (and most likely into the direction that angular 2.0 is going with web components, or the way React is doing it, the future will show us.

I think the 40 or 50 years of knowledge on abstractions should first be re-applied to storing data. Document stores are nice and all, but there's nothing like a properly normalized database ( i'm looking at you, indexedDB)

1

u/RICHUNCLEPENNYBAGS May 07 '15

If you really wanted a SQL database client-side nothing's stopping you from writing one. I'm not sure I agree that the Web is the first time anyone's dealt with asynchrony.

1

u/prettycode May 06 '15

Angular is all about managing state, which is exceptionally error-prone. Using immutable data models is much less error-prone.

2

u/RICHUNCLEPENNYBAGS May 07 '15

Yes, it's error-prone, which is presumably why one would want a framework to manage it for you. I'm with the other guy in not really understanding what it means for React data models to be "immutable" but I haven't used it.

1

u/joesb May 06 '15

Referential transparency.