Lately there has been some news around Angular 2.0. There are some odd things about working with Angular 1.3 that I’ve experienced during project work, which they have tried to address. However, it got ugly on various parts.
In this blogpost I discuss various changes, as I could interpret from blogposts and conference videos. Note that Angular 2.0 is not yet ready.
The Good
First and foremost, I really like the way they put performance on the agenda, especially for less powerful devices such as smartphones. It is good to discuss performance as an ongoing topic while building any kind of application, web-app or non-web-app.
A thing that went weird in Angular was the scoping, especially communicating between nested scopes of several directives. Communicating up the tree was really hard to do, and it seems the Angular team has fixed the issue by removing separate scopes. In general, it will be easier to talk between various components.
Directives for elements are now ComponentDirectives. The other types of directives have also various names, and that makes a lot of sense because the code will be less cluttered. This means controllers are gone as well, because most controllers would control the element directives.
Bundling up the various forms of directives, and combine them with services will be made easy by removing the dependency injection. Instead, Angular 2.0 will use EcmaScript 6 modules. In the same style, jqLite will be removed in favour of using bare DOM methods.
The Bad
There is a new syntax for templates, with some interesting ideas. Interesting in the sense, that it might be hard for people, software and various tools to cope with it.
The two types bindings, event and property binding:
<form (submit)="lookup()">
<input [value]="term">
</form>
Although it is good to have the distinction between the two types, the fact that there has to be a full HTML+Angular template parser in the code is a bit sad. Why not go all the way, and have tiny templates, that might be easier to parse with JavaScript as well?
There is an off thing to compile templates to be included in the JavaScript, but having to have to-be-parsed HTML there makes no sense to me.
The Ugly
The release date is set to the far future, somewhere at the beginning of 2016 we will be able to really try and use Angular 2.0. However, the support for Angular 1.3 will be discontinued shortly after it will get released.
For the very distinctive changes Angular 2.0 has, as compared to Angular 1.3, one would expect some more time than just 18 months to rewrite all of the code base. Rewriting is a necessity, and no company will like standing still with developments on any software project.
The Extremely Ugly
Google invented a new metalanguage to make all this happen for Angular 2.0: Atscript, which compiles to EcmaScript 6. To build a web app with Angular 2.0 requires writing Atscript. The new language is some syntactic sugar that will make the web a bit more obese.
If a small, bigger or large entity who makes software, doesn’t like a specific bit of JavaScript, they should talk with the working groups instead of ‘inventing’ a new metalanguage. There are enough already.
To conclude
I really hope the Angular team listens to the various feedback it will receive. I really like the new way directives work and how dependancies are handled. I hope they are aware of the impact the changes will have, especially those mentioned in the ‘ugly’-sections.
Written by Arjan Eising
Member discussion