zymr-es6-and-angular-2

What’s new in Angular 2.0 makes for a difficult question. A better way to pose the question may be, “What’s different in Angular 2.0?” That’s because the first thing developers should know about Angular 2.0 is that there is no upgrade path from Angular 1.x– Angular 2.0 is a completely new framework.

What is Angular?

AngularJS is, of course, the popular open-source framework for building rich web applications. According to libscore.com, AngularJS is being used by over 12,000 of the top million websites as of Libscore’s May 2016 data.

Mobile and Modern

The Angular 2.0 team took a mobile-first strategy with the belief that making sites fast and flexible for mobile was a harder problem than writing for desktop. With that in mind, developers should find Angular 2.0 a good place to develop responsive and mobile-ready applications. The Angular team also chose to focus on so-called “evergreen” browsers that update automatically. These include newer versions of:

  • Chrome,
  • Safari,
  • Firefox,
  • Internet Explorer,
  • Mobile Safari,
  • Android and
  • Microsoft’s Edge.

Notably, Angular 2.0 supports Internet Explorer 9, which is not an evergreen browser. More details are available here. The limited browser support means that developers need fewer workarounds to support older, troublesome browsers. The downside is that some users are still using older browsers, and those users won’t be able to use applications written in Angular 2.0.

Angular 2.0 is also designed for ECMAScript 6 (ES6), the latest version of JavaScript. Developers will find ES6 easier to use due to its better syntax for simulating classes, inheritance and ES6’s support for modules. Modules allow for better organization of large JavaScript codebases. The Angular team recommends the use of Microsoft’s TypeScript for backward compatibility with browsers that don’t support ES6.

Nuts and Bolts

Angular 2.0 includes some new ways of doing things, and some improvements on Angular 1.x:

  • Better dependency injection
  • Dynamic Loading
  • Asynchronous Template Compilation
  • Diary.js logging
  • Templating

Angular 2.0 also does away with controllers and $scope and replaces them with components and directives.

Who Should Switch?

For practical purposes, Angular 2.0 should probably be best thought of as an entirely new framework rather than an “upgrade” to Angular 1.x. There is no upgrade path from 1.x to 2.0: Any 1.x implementations will need to be rewritten for 2.0. Developers who are currently using Angular 1.x are probably best-served to stick with 1.x for now until Angular 2.0 brings a large enough advantage that switching would be beneficial. Developers who are writing new applications have a tougher decision: stick with tried-and-true 1.x but run the risk of being left behind as 2.0 matures, or take advantage of the speed and new features of Angular 2.0 but possibly be stuck if adoption isn’t widespread and Angular 2.0 stops being updated?

The advantages of Angular 2.0 over Angular 1.x are substantial and include support for EC6, better speed and flexibility for mobile implementations, and improved dependency injection. But the team’s decision to leave 1.x applications behind means that the developers must be in charge to make those difficult decisions.

This article was authored by Sanjay Patel, who is a Senior Software Engineer at Zymr.

Recent Posts

Popular Posts

0 comments

Leave a Reply

© 2017, Zymr, Inc. All Rights Reserved.