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

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:
restrict: 'EA',
require: '^?ngModel',
scope: {
  ngModel: '=',
  foo: '&',
  bar: '@'
}
Allowing directives to be defined as CSS classes is confusing for code maintainers (e.g. "Is this a CSS class or a directive?")
  • 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.



Comments

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

Post a Comment

Keep it clean and professional...

Popular Posts