Why I Find Angular 1 Less Interesting For New Projects
Angular is old (in the sense that it hasn’t kept up with the way JavaScript has evolved over the years) and lacks the foresight that its competitors have, most of which had the opportunity to take advantage of learning from Angular’s mistakes.
The long version
Angular has made several mistakes that will be mostly corrected with Angular 2, but the lack true compatibility with Angular 1 means that it’s hard to be excited about using a technology that really doesn’t have much of a future left. A year ago I had a different opinion, but today we’re truly inching closer to the release of Angular 2.
New applications written in Angular 1 are simply more difficult to maintain than it would be with a competiting modern technology. That fact, the assumption that there will be a reduced focus that will inevitably happen when Angular 2 comes out, and the fact that Angular 1 is such an enormous framework that a small set of contributors could have no hope of maintaining/improving it alone means that new things written in Angular 1 are going to get stale.
It’s hard to get enthusiastic about such a likely outcome.
Mistakes of Angular
As for the mistakes/maintainability of Angular 1, let’s just observe the syntax and vocabulary it has chosen to use.
- Directives (a name which completely obscures the underlying concept)
- Filters (which have nothing to do with filtering, also obscuring the concept)
- Modules (which clashes with modern JS modules and leads to at least some degree of confusion)
- Scope
- Services
- Controllers
- Dependency Injection (which is a great concept to learn in general, but probably not desireable to require to get a single-component Todo-app to run)
- Components (recently added in 1.5)
You’re also suggested to already be aware of at least one of MVC, MVVM, MVP, MV-Whatever because if you’re not reasonably strong at one of them, you’re almost certain to structure an application in an incomprehensible manner.
As a design choice, an obscure vocabulary often affords you greater expressive power (meaning less syntax with more things done), but Angular’s choice of API makes it often fairly verbose as well with lots of setup and ceremony to create a simple project. That’s probably partially an artifact of the time it came from. Back in 2009-2010, the API was probably very modern considering the features of JavaScript at the time (although I certainly don’t know exactly how it looked back then, I can infer from where it is now). But today, not so much.
It Can Be (And Is) Better
It’s so much stuff to learn and it’s extremely difficult to immerse yourself in it at first because it’s just too much new vocabulary to bring up a simple app. In my experience, Angular is very verbose syntax-wise, and the API is really difficult to discover/grok for pretty much anyone except those who already know a lot of it.
This fact becomes extremely obvious once you try something like Mithril where merely understanding CSS selectors and basic JavaScript, necessary prerequisites for working with an HTML site anyway, is sufficient to create a simple app. Mithril also advocates MVC, but the getting started experience shows enough knowledge of it that pre-existing experience doesn’t feel required.
Of course, I’m not a beginner in that regard, so it feels difficult to really judge it based on that. But that said, I wasn’t absolutely brand new at MVC when I learned Angular, but I felt it made it extremely difficult to see the “correct” way to structure an Angular application. Even today people, “experts” even, keep changing their minds about Angular architecture – nothing feels obviously “correct”, just differing degrees of “Eh, looks fairly good” … this is a clear sign of a fundamental problem, in my eyes.
Compare
Just look at the Angular Homepage’s examples and compare it with the examples Mithril shows.
The very first Angular example shows you a way you should never use to write an application. The next example shows a simple Todo application spanning several files introducing you to several new concepts such as the numerous ng-* tags that litter your HTML (and they even embolden them to make them really stand out).
Mithril, on the other hand, shows a ~30 line, single file example of a carousel that involves making web requests, building a view, and dynamically changing that view. Despite introducing the reader to an initially “more complex” example, the example is significantly clearer and, more importantly, the structure shown for the first example is viable for real applications. Mithril does have a guided example of building a Todo application, but the ultimate end-result keeps the code for that one component together in one file, which I find easier to deal with. A few small things that change together shouldn’t be spread across many different files (a fact that Angular 2 is embracing).
The Take-Away Message
This directly affects the barrier to entry for a new-hire to maintain an application written in the framework. I could actually feel fairly comfortable with someone learning the basics of something like Mithril in a day and maintaining something written in it.
Angular? We’re talking probably at least a week of training and questions, realistically. Of course, there’s lots of pre-existing applications written in Angular and the higher barrier to entry means that it’s a valuable skill to already have. But spending the time attaining that skill is becoming less justifiable as we go along, and it’s certainly becoming less exciting to start a new project in it.
Summary
Maybe I’m Too Harsh
It feels like I’m being overly harsh about Angular, but after recently looking at a few other frameworks, it seems pretty apparent that Angular 1 is outmatched by the newest frameworks. Angular 2 might change that, but I can already use many very viable alternatives today.
Some of the frameworks, like Mithril, I feel I could maintain myself (yes, all 2000 lines of it – some of which I could trim out and use other components for if needed – instead of 20k+ for something like Angular) because they’re so minimal and simple.
Because of all this, I’m just finding Angular 1 less interesting for new projects.