In the years since Angular 1.x was released, web development tools have continued to rapidly evolve. Angular 2 takes full advantage of the feedback from Angular 1.x users to shape many of the new features.
Angular 2 is in beta and has significantly improved on Angular 1.x. The entire framework has been affected by the upgrades. Upgrading applications from Angular 1.x to 2 is not trivial and there is some uncertainty as to the benefits of upgrading. In our last blog post, we looked at when to use Angular 2 on new applications. Here we will examine existing apps.
In our opinion, with a few exceptions stated below, it's almost always going to be advantageous for development teams to upgrade from Angular 1.x to Angular 2.x. The new framework has numerous improvements and features that will benefit most developers, as well as end users.
Some general considerations when deciding to upgrade:
- The larger the application, the more work required to upgrade to Angular 2
- More complex applications will see more performance gains than simple apps
- Applications written in Angular 2 will be easier to analyze statically
- Angular 2 will likely have a longer support window than Angular 1.x
- Development tooling, and the Angular 2 ecosystem will be more modern, and comprehensive than with Angular 1.x
- Developers generally like working with newer technologies. Angular 2 can help keep them engaged.
In general, it's always a good idea to keep vendor libraries up to date. While Angular 1.x will still be supported for some time, it is reasonable to assume that eventually 1.x will be deprecated.
There are some specific cases where upgrading to Angular 2 will provide more obvious benefits.
Some of the Angular 2 features that significantly improve mobile:
- First class touch events
- Mobile memory and CPU limitations were considered from the start of Angular 2 development
- Isomorphic rendering provides new options to make applications feel faster
- NativeScript has bindings that work directly with Angular 2, simplifying hybrid applications
- Angular 2 features new change detection strategies that are faster, more scalable, and less resource intensive
Large applications, with tens of thousands of lines of code also have a strong case for upgrading to Angular 2, and/or ES2015 or TypeScript. These applications can be a lot of work to upgrade, but they will see significant performance and maintainability gains.
- ES2015 modules and a module loader dramatically improve organization
- Angular 2 has less boilerplate Arrow functions, making many code constructs easier to read
- Routing has been based on the popular UI router project
- State management has been improved
Projects That Need Extensive Maintenance
Applications in need of maintenance are also an upgrade case. These kinds of programs might still be serving a purpose, but also, be showing their age. They will likely need a lot of care to upgrade properly, but such is the nature of refactoring. Any Angular 1.x code that is being fixed should at the very least be upgraded to an Angular 2 style.
The Angular 1.x series has been slowly shifting towards the new style, and this is reflected in Angular 1.5's component method. There are also emerging tools like ng-forward that let Angular 1.x developers write classic Angular applications that read like Angular 2 applications.
The Case For Not Migrating To
Angular 2 is great, but there are still some cases where migrating doesn't make sense, typically because of cost, or interest.
Projects that are functioning, and have met their acceptance criteria and are largely down to minor bug fixes do not need to be upgraded to Angular 2 just for the sake of it.
There are also projects that make extensive use of third party modules. Upgrading these kinds of projects might not be initially viable, but in the long term, it is reasonable to expect that maintainers of worthwhile modules will upgrade, or rewrite them for Angular 2. In some cases, Angular 2 itself might obviate the need for a third party module.
Other Key Angular 2 Resources
Rangle's Angular 2 Newsletter
Sign up for our dedicated Angular 2.0 newsletter, to gain insights on best practices and how to strategize your shift: