What's the difference between Angular 2 and Dart?
I read you can use AngularJS together with dart. What does that mean? Aren't they both a JavaScript replacement?
What's the difference between Angular 2 and Dart?
I read you can use AngularJS together with dart. What does that mean? Aren't they both a JavaScript replacement?
Update (2018/01)
While the template syntax is still quite similar, other things like configuring DI and registering components and also lifecycle callbacks are diverging more and more between the Dart and TS flavors of Angular since the two versions were split in May 2016 to be developed independently.
Original
TypeScript is a superset of JavaScript, it just allows to use JS in a more "sane" way.
Dart is further away from JavaScript with it's own language semantics. Dart can be translated to JS though.
Which of the supported languages is the right one for you depends mostly on your requirements or personal preference (or the ones of your management).
[prop]="value"`
[attr.attrName]="value"
prop="{{value}}"`
attr.attrName="{{value}}"
(event)="..."
<div *ngFor="...">
One difference that comes to mind is that the TS/JS version got the <ng-container>
which is not (yet) available in Dart.
@ContentChildren()
behaves a bit different.
[ngClass]="{cName: value}
will cause an error in Dart if cName
is not a known identifier in the current scope while in JS/TS cName
will just be used literally.
[attr.someAttr]="someProp ?? true" // Dart only
Angular2 Dart doesn't have NgModule
which was mainly introduced for lazy loading with the router. Dart has it's own lazy loading story and doesn't need NgModule
TS/JS supports different platforms like server-side rendering, WebWorker. Angular2 Dart currently doesn't provide these.
There is ongoing work to make Darts own HTML abstraction dart:html
compatible with server-side code, which will probably allow server-side rendering. WebWorkers will probably also supported eventually but in a different way than in TS/JS.
For Dart there is no dynamic platform. In JS/TS it is supported to compile components at runtime. That's not supported in Dart and it probably never will be.
Dart seems to do a bit better in AoT with tree-shaking for output size and performance (not entirely sure - needs benchmarks)
Dart has it's own build story and this part works entirely different than JS/TS.
Darts DOM abstraction layer dart:html
includes a lot of abstraction for different browsers where JS/TS requires polyfills.
Angular is not a JavaScript replacement, it is a framework for building web applications. There are 3 language flavors of Angular, for JavaScript, Typescript and Dart.
Typescript and Dart can both be described as JavaScript 'replacements', insomuch as one can program in them instead of JavaScript to build web applications.
Dart can also be used for non-web application programming, where Java, Ruby or Python might be used.
There is also a Dart mobile application framework under development.