Google rewrites its Angular JavaScript framework

15.12.2015
Angular 2, a re-architected, rewritten version of the popular JavaScript framework also known as AngularJS, goes to a beta release stage today, with general availability planned for early-2016.

The upgrade features enhancements for speed in rendering and updating pages, near-initial rendering, and support for building cross-platform native mobile apps for Google Android and Apple iOS. "It's eight times faster than Angular 1," said Brad Green, Google director of engineering in charge of Angular.

"We built the change detection algorithm so that all of its commands are generated so that they can be inlined by the JavaScript virtual machine," leading to faster change detection, said Green. Version 2 also takes advantage of processor registers instead of relying on a virtual table lookup; the upgrade ensures the virtual machine always knows what type, such as int, string, or float, is coming in.

For mobile application developers, Angular has worked with Telerik on NativeScript for building apps via Angular and JavaScript but using native components. "In Angular 2, we change the architecture dramatically, where we can decouple the rendering from the DOM so that we can actually have other renderers," Green said. Developers can adopt a single framework for developing across the desktop, mobile Web, and mobile installed app realms. With version 1, mobile development was done by using the Ionic framework on top of Angular, using Web views to deploy installed mobile apps. Developers have the option of still using Ionic with a new version configured for Angular 2.

To make interfaces fast and run well on mobile, Angular 2 enables an application to run inside a Web worker, thus making the UI responsive regardless of what the application is doing, Green explained. The Angular Universal feature, meanwhile, provides for performance by allowing for an application to be first rendered in just HTML and CSS, with the first page of an app running inside of Node.js on a server.

Written in TypeScript, Angular 2 already has been use at Google, which deployed it at properties like Adwords and Google Fiber. "What we're saying is that we're confident that other teams can now build on top of Angular 2," Green said. While version 2 constitutes a "rewrite and a breaking change," Google is offering a library called ng Upgrade, for mixing Angular 1 and 2 inside of an application. Developers can start writing Angular 2 components inside of their Angular 1 application, and previous features including as dependency injection and data binding remain.

In an October 2013 interview with InfoWorld, Misko Hevery, co-author of Angular, cited the concept of directives, in which HTML drives application assembly as a differentiator, along with dependency injection. But version 2 mostly replaces directives with a components approach, which anticipates future Web Components specifications, such as Shadow DOM and HTML Imports.

Before moving to the final release, Angular's builders plan to reduce the Angular 2 binary size, make the Angular CLI (Command Line Interface) usable throughout the development process, and develop a more developer-friendly API for the Angular component router. Support for animations and I18n internationalization and L10n localization also is planned. Other features, planned for general availability in coming months include better startup times and more documentation, particularly around ECMAScript 5 and 6 usage. Angular's developers are also looking at an architectural style guide, more support for mobile and installable mobile apps, Material Design components for Angular 2, a tools platform for deep IDE support, and better support for ECMAScript 6 and the Babel compiler.

Initially developed in 2009, Angular has been used by major companies such as Target, Walgreen's, and United Airlines, Green said. A recent survey of 5,350 JavaScript developers, conducted by JavaScript consultant PonyFoo, found Angular to be the second-most-widely used framework, with 47.8 percent using. Only Facebook's React framework, with 57.6 percent, fared better.

(www.infoworld.com)

Paul Krill

Zur Startseite