What is the difference between Angular 2 TS and Angular 2 Dart?

What is the difference between Angular 2 and Dart?

I read that you can use AngularJS with darts. What does it mean? Aren't they a replacement for JavaScript?

+5
source share
2 answers

Update (2018/01)

While the template syntax is still very similar, other things, such as configuring DI and component registrations, as well as lifecycle callbacks, are increasingly different between Dart and TS Angular flavors, as the two versions were separated in May 2016 independently from friend.

Original

TypeScript is a superset of JavaScript, it just allows you to use JS in a more "smart" way.

Dart is further from JavaScript with its own language semantics. Dart can be translated to JS though.

Which of the supported languages ​​is right for you depends mainly on your requirements or personal preferences (or your leadership).

  • The template binding syntax is almost the same for all three languages
[prop]="value"` [attr.attrName]="value" prop="{{value}}"` attr.attrName="{{value}}" (event)="..." <div *ngFor="..."> 

The only difference that comes to mind is that the TS / JS version got <ng-container> , which is not yet available in Dart. @ContentChildren() behaves a little differently.

  • The language constructs supported in binding expressions are already very different, since they are a subset of the language used.
 [ngClass]="{cName: value} 

will result in an error in Dart if cName not a known identifier in the current area, and in JS / TS cName will be used literally.

 [attr.someAttr]="someProp ?? true" // Dart only 
  • Angular2 There is no NgModule in Dart, which was mainly introduced for lazy loading with a router. Dart has his lazy boot story and doesn't need NgModule

  • TS / JS supports various platforms, such as server-side rendering, WebWorker. Angular2 Dart does not currently provide them.
    Work is ongoing to make its own HTML abstraction, Darts dart:html compatible with server code, which is likely to allow server-side rendering. WebWorkers will probably also be supported in the end, but differently than in TS / JS.

  • There is no dynamic platform for Dart. JS / TS supports compilation of components at run time. This is not supported in Dart, and it probably will never be.

  • Dart seems to have improved slightly in AoT with tree shake for output size and performance (not quite sure if tests are needed)

  • Darth has his own story of creation, and this part works in a completely different way than JS / TS.

  • Darts abstraction level DOM dart:html includes many abstractions for different browsers, where JS / TS requires polyfill.

+11
source

Angular is not a replacement for JavaScript, it is the foundation for building web applications. There are 3 Angular language styles for JavaScript, Typescript, and Dart.

Typescript and Dart can be described as "replacements" for JavaScript, as they can be programmed instead of JavaScript to create web applications.

Dart can also be used for programming without web applications where Java, Ruby or Python can be used.

There is also a Dart mobile application platform in development.

+2
source

Source: https://habr.com/ru/post/1260565/


All Articles