Last month I posted a very long write-up on AngularJS 1.x and 2.0 based on watching all the videos from ng-conf 2015.
I showed my writing to Brad Green from the AngularJS team, who liked it, and had some very useful comments to share, with corrections and additional details on Angular 2.0 side especially.
Here it is:
Brad Green’s Comment
- Speed One way data binding (instead of 2-way data binding, which has implications on forms directives changing a bit) and changing the way scopes work -now called zones, and don’t requite $digest or $apply pain or having a special name- among other internal changes are reducing memory and DOM writes, causing possible 10x speed increases.
This is certainly a complex subject. As it turns out, none of the bits you list actually are responsible for the increased speed.
One of the confusing bits is likely that we’ve adopted a unidirectional data-flow for Angular 2’s change detection as opposed to Angular 1’s unconstrained data flow. This has had a slight improvement for speed because we no longer have to do multiple digest cycles to ensure all changes propagate through your model.
This is a separate issue from two-way data binding which is mostly a template syntax issue. There is still a way to get data into and out of forms automatically like in Angular 1’s ng-model, but with different syntax.
Other bits that have helped for Angular 2’s performance:
Generating change detection code to ensure that it they types don’t change resulting in VM’s ability to use a monomorphic inlining strategy (5-10x speed improvement, dramatically lower memory requirements)
Re-using DOM templates for your views (helps when re-visiting a view and in virtual scrolling)
Having a pluggable change detection scheme that can increase speed when you use immutable data structures or Observable objects
Angular 2 Directives also use the
<template>element from the web component specification.
Yes, ShadowDOM will be optional, but on by default.
We use Traceur now, but will be switching to the TypeScript tool chain once we implement Dart generation within it.
There are now actually over 1 million 30-day-active developers on angularjs.org. I just wish it could have crossed the line before the conference. :)
In Angular 1, we’re also looking into adding a mechanism to make it easier to do lazy code loading without all the hacks necessary today. We’re not committed to it as we’re not sure it’s possible to do safely, but we’d like to do it if possible.
The “Continue to plan in public” comments were to the effect that yes, we’ll share our notes but also take your direction in terms of planning release by GitHub issues and feedback on our docs.
Though it’s true that some of us aren’t familiar with ui-router, Brian and others working on the new Router (official name TBD) have been collaborating directly with the ui-router authors. Yes, we have gotten inspiration from Ember for the new router and even share some code, but the full spec comes from many sources, including ui-router and even server-side routing libraries.
My post has been an issue to the AngularJS and Web Developer newsletter I send every now and then.
If this sounds interesting to you, get the newsletter from here: Get The Newsletter
Finally, here’s the original reply as I got it from Brad:
— Brad Green (@bradlygreen)
I will be writing soon for the newsletter about more Angular 2.0 news and sample codes that have been circling the web recently, stay tuned!
P.S. Please help me out by checking this offer, then look below for a small Thank You.
How did I learn that?
As a bonus for coming here, I'm giving away a free newsletter for web developers that you can sign up for from here.
It's not an anything-and-everything link list. It's thoughtfully collected picks of articles and tools, that focus on Angular 2, ASP.NET 5, and other fullstack developer goodies.