Angular 1.x or Angular 2 - what to select for your next project?

Are you in the process of deciding which version of AngularJS to use in your new project? Read my comments below. I don’t want to go as far as saying...

Are you in the process of deciding which version of AngularJS to use in your new project? Read my comments below.

I don’t want to go as far as saying that going with Angular 1 could end up being a future risk of your new project, but there are some considerable differences between Angular 1.x and Angular 2 versions, which everyone should be aware of.

Angular 2 is in beta already. Actually, this is the time line: Angular 2 was announced on March 2014, earlier in 2015 went to Alpha and as of December 15, 2015 it is in beta stage. So the project is moving very fast towards general stable release.  In Google’s statement: “Beta means we're now confident that most developers can be successful building large applications using Angular 2”. Google is already migrating several large projects into Angular 2  internally -  AdWords, Fiber, etc.

Couple of notes from my research:

- **Angular 1 is aging** – the code base for Angular dates back to 2009. Lot of things in 2009 didn’t exist back then. Right now we are looking at the Shadow DOM, and ES6 modules, and ES6 in general, and that wasn't really around then.

- **Angular 2 sits on top of web standards** - For example, now with Angular2 we don't need things like transclusion anymore, because that's what the Shadow DOM does and it provides it natively (Shadow DOM basically refers to the ability of the browser to include a subtree of DOM elements into the rendering of a document). Also ES6 modules - they now replace Angular Modules. So, Angular 2 wants to sit on top of web standards (ECMAScript standard) instead of the old way where Angular 1 was creating a standard of its own. ES6 I guess, because they’re pushing for TypeScript, and that’s basically an extension of ECMAScript (TypeScript = ES6 + Types + Annotations). And TypeScript being actually from Microsoft it also means Angular 2 will likely get more traction (and become popular for .NET developers as well). Bottom line is: Angular 2 wants to play nice as the web evolves.

- **Learning Curve & Time to Code -** Another thing is the Simple Cognitive Model used in Angular 2. Angular 1.x has many concepts and concepts come with a learning curve. You can spend an entire day just learning about all of the different things of a controller in Angular 1 and that’s just one concept, then there are other concepts like factory, service, provider, directive, transclusion, module, etc. In version 2, the motivation seems to be a simple cognitive model. In Angular 2 - directives were considerably simplified, forms and validation is changed as well and entire Angular 2 is entirely component based (meaning Controllers and $scope are no longer used).

- **Angular 2 – MIT licensed **– Angular 2 and all its related libraries, code snippets and examples were already moved to the [MIT license](http://angularjs.blogspot.ca/2016/01/angular-2-mit-open-source-licensed.html)

- **Angular 2 & Mobile** – A2 is designed from the ground-up for mobile and optimized for memory efficiency and less CPU cycles.

- **Performance** - Speed is obviously very important. Angular2 in alpha was already 5x faster than Angular 1. Angular 2 in beta claims to be anywhere from 5-10 times faster. Recently the Meteor team did a front-end frameworks performance shoot-out and Angular 2 came out first, overtaking React and every other framework. Following chart represents a very complex Angular application, very deep rooted, nested components:

1-13-2016 8-11-31 AM

Bottom line, designing any large and complex web application with Angular 1.x (in early 2016 and after) may come with certain risks mostly because by the time you get to a release, Angular 2 will be out of beta and most companies will already be moving away from Angular 1.x. So if you don’t like the idea of doing a complete rewrite of your app shortly after its general release, simply because Angular 2 is a lot faster, plays a lot nicer with web standards (used by all browsers) and is generally easier to code with and train for, go with Angular 2.  Another thing is that rewrite between Angular 2 and 2.x would be marginally less costly exercise as compared to rewrite between two major versions.

As far as general release availability goes, this is what Google says today:  "We're really close. There's just a couple more things we want to do. We want to finish the docs and there's some P1 issues -- there's about 50 of them -- we want to burn down before we tell you: "The water's completely safe, come on in".

How far is Angular 2 from final release? Check out this website: http://juristr.com/apps/ng2beta/

Some food for thought…