Things I dislike about AngularJS
Update: I was watching the development of AngularJS 2.0 with interest due to its modern ES6 approach, but the lack of backward-compatibility irked a lot of die-hard 1.x fans and caused a mini-exodus, including Rob Eisenberg. Rob went on to create a JavaScript platform/framework called Aurelia that looks as promising as Polymer so I've updated my recommendation below accordingly.
~~~~~
Preface: I like Google and the goals of AngularJS and my intention is not to start a flame war, but it seems there are a lot of drink-the-Kool-Aid! posts about how awesome AngularJS is and I wanted to provide some counter points of caution (based on my experience) of what I dislike about the current state of AngularJS:
Documentation is spotty and the API is so complex you can't code without constantly referencing it (i.e. non-intuitive)
Too many service types with overlapping functionality and poor guidance on proper use cases
Non-intuitive terms, such as transclude, which refer to non-intuitive concepts, such as:
Directives are prone to memory leaks
Custom $digest loop and $watch dirty-checking aren't designed to scale well for slow mobile devices, heavy processing, or 50+ fps
No namespace enforcement or best practices can lead to naming collisions
$ variable prefix is confusing when mixing code with jQuery (also confusing to use $scope in controllers but scope in the link function)
Auto camel-to-snake-to-camel casing is confusing to programmers new to Angular, muddles code tracing, and is easy to forget to transpose in the correct context
Too much secret decoder ring enigma code:
Explosion of widely available, loosely moderated directive code may result in difficult maintenance and security protection (e.g. "Where did this directive come from? What version is this directive? Is there a newer version? Are there known security vulnerabilities with this directive? Is there a more robust or popular directive out there for this functionality? ...")
___________________________
For the moment, I'm putting my money on Polymer (check out their elements catalog) or Aurelia (see comparison to Angular 2.0 here and here). Others seem to like Closure. Another one to keep an eye on is Riot / RiotControl.
~~~~~
Preface: I like Google and the goals of AngularJS and my intention is not to start a flame war, but it seems there are a lot of drink-the-Kool-Aid! posts about how awesome AngularJS is and I wanted to provide some counter points of caution (based on my experience) of what I dislike about the current state of AngularJS:
Documentation is spotty and the API is so complex you can't code without constantly referencing it (i.e. non-intuitive)
- https://news.ycombinator.com/item?id=6152291
- http://www.reddit.com/r/javascript/comments/1ecbjn/polymer_a_new_web_framework_by_google_designed_to/ca17bk8
- http://www.jacopretorius.net/2013/07/angularjs-pain-points.html
- http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/angularjs-vs-knockout-final-thoughts-9
- http://lhorie.blogspot.com/2013/09/things-that-suck-in-angularjs.html
Too many service types with overlapping functionality and poor guidance on proper use cases
- http://angular-tips.com/blog/2013/08/understanding-service-types/
- http://slides.wesalvaro.com/20121113/#/2/7
- http://docs.angularjs.org/api/AUTO.$provide#comment-891008169
Non-intuitive terms, such as transclude, which refer to non-intuitive concepts, such as:
"transclusion refers to compiling the content of the element and making the source available to the directive. The transcluded function is pre-bound to the calling scope, so it has access to the current calling scope." — source
Directives are prone to memory leaks
- http://stackoverflow.com/questions/17203005/angularjs-directive-destroy
- http://odetocode.com/blogs/scott/archive/2013/07/16/angularjs-listening-for-destroy.aspx
Custom $digest loop and $watch dirty-checking aren't designed to scale well for slow mobile devices, heavy processing, or 50+ fps
- http://mrbluecoat.blogspot.com/2013/08/in-regards-to-javascript-library.html
- https://www.youtube.com/watch?feature=player_detailpage&v=ZhfUv0spHCY#t=1992
- http://angular-tips.com/blog/2013/08/removing-the-unneeded-watches/
- http://www.bennadel.com/blog/2489-How-Often-Do-Filters-Execute-In-AngularJS.htm
- http://www.bennadel.com/blog/2472-HashKeyCopier-An-AngularJS-Utility-Class-For-Merging-Cached-And-Live-Data.htm
- https://www.youtube.com/watch?feature=player_detailpage&v=VO--VXFJnmE#t=530
- http://wesleyhales.com/blog/2013/10/23/Basic-Screen-Updates-with-Angular-and-requestAnimationFrame/
- https://www.youtube.com/watch?feature=player_detailpage&v=mfOh-J-9BY0#t=120
No namespace enforcement or best practices can lead to naming collisions
$ variable prefix is confusing when mixing code with jQuery (also confusing to use $scope in controllers but scope in the link function)
Auto camel-to-snake-to-camel casing is confusing to programmers new to Angular, muddles code tracing, and is easy to forget to transpose in the correct context
Too much secret decoder ring enigma code:
restrict: 'EA',Allowing directives to be defined as CSS classes is confusing for code maintainers (e.g. "Is this a CSS class or a directive?")
require: '^?ngModel',
scope: {
ngModel: '=',
foo: '&',
bar: '@'
}
- Yes, I know I don't have to define directives as a CSS class, but it's the principle that I can that bothers me. If I inherit code that uses AngularJS, I am now no longer certain if class="foo" refers to a CSS class, an Angular directive, or both. It also makes code refactoring much harder.
Explosion of widely available, loosely moderated directive code may result in difficult maintenance and security protection (e.g. "Where did this directive come from? What version is this directive? Is there a newer version? Are there known security vulnerabilities with this directive? Is there a more robust or popular directive out there for this functionality? ...")
___________________________
For the moment, I'm putting my money on Polymer (check out their elements catalog) or Aurelia (see comparison to Angular 2.0 here and here). Others seem to like Closure. Another one to keep an eye on is Riot / RiotControl.
great
ReplyDeleteP.S. There's also been a lot of buzz recently regarding Vue (https://vuejs.org/) and for the CSS fans there's BEM (http://getbem.com/)
ReplyDelete