76

I know a bit about Angular.js, but I want to teach myself Dart and Angular.dart now. I'm a bit curious what the differences between the two are, though. The Angular.dart tutorial specifically says it won't compare the two. Does anyone who has used both have a perspective on what the differences are?

d4nyll
  • 11,811
  • 6
  • 54
  • 68
CorayThan
  • 17,174
  • 28
  • 113
  • 161
  • 3
    Yes ... and one is older and more mature than the other two, but I was thinking of the less obvious differences. – CorayThan Nov 15 '13 at 06:29

3 Answers3

96

Update #2 (Aug '16) A Dart version of Angular is now maintained by the Dart team on Github: dart/angular2 on github

Update: The AngularDart project is mothballed and has been superseded by Angular2. Angular2 is the most recent iteration of Angular and works in Dart.

The original answer below compares AngularDart and AngularJS 1.x.

AngularDart and AngularJS are both maintained by the Angular team. We've taken a lot of knowledge from the JS side and applied it to Dart. We have also taken a lot of code and ported it straight to the Dart world.

At a technical level, in the core of Angular:

  • The expression language is compatible between the two versions. The AngularDart parser started as a straight port from JS but has been evolving on its own. A big difference there is that the Dart parser supports multiple backends, including a Dart code generator.

  • The DI system is different. In Dart it is class based where in Javascript it is symbol based.

  • The compiler has been completely rewritten in the Dart version. This means that directives behave differently and now there is a distinction between "structural directives" which modify the DOM, "decorative directives" and components.

  • ng-transclude has "melted into the browser", replaced by the standard shadow DOM.

  • directive controllers have been merged into components

  • directives in AngularDart are declared with an annotated class. link / compile functions are replaced with an apply function

  • In AngularDart, the scope is digested automatically through Dart zones, eliminated the need from scope.$apply.

  • AngularDart has a concept of attribute maps which hasn't made it back to AngularJS yet. This means that directives should need many fewer scope.$watches or even a dependency on the Scope.

There may be other differences, but that is a good list to get you started.

James deBoer
  • 2,477
  • 15
  • 17
  • 2
    Any idea when it will be in a usable state? Even some basic functions are missing right now it seems and am so excited to start using Dart :( – Samuel Katz Dec 30 '13 at 19:11
  • @SalmanPK AngularDart is usable. What features are your missing? – James deBoer Jan 02 '14 at 18:24
  • [ngModel](https://github.com/angular/angular.dart/issues/131) and [ngForm](https://github.com/angular/angular.dart/issues/113) – Samuel Katz Jan 03 '14 at 01:56
  • Basic support for both are already available. We are still working on a few additional features (e.g. validation). – James deBoer Jan 03 '14 at 02:02
  • 7
    one obvious difference would be browser compatibility - angular.js states "Safari, Chrome, Firefox, Opera, IE8, IE9 and mobile browsers (Android, Chrome Mobile, iOS Safari)" while there is no such claim for angular.dart (haven't found anything on their website) - dart itself targets ECMAScript 5 (>= IE9), but angular.dart uses Shadow DOM and polymer's polyfill for it - and polymer's only target are "evergreen" browsers, not even mentioning mobile browsers. Does anyone know if this is a correct observation? – Herbert Poul Mar 15 '14 at 19:25
  • JavaScript ES6 is coming out with some new features like the ability to define classes using the `class` keyword... That might allow dependency injection to be more like Dart's, etc. – trusktr Apr 01 '14 at 04:39
  • Is AngularDart stable ? – Sagar May 26 '15 at 08:43
17

So the first difference is pretty obvious: AngularJS is written in JavaScript whereas Angular.dart is written in dart.

While Angular.dart follows the core principles of AngularJS it seems to be a bit of a playground for new features to evolve. I guess the core team takes all the learnings from AngularJS and tries to implement things just slightly better for the Angular.dart version. Currently it seems as if a bunch of things are first implemented in the dart version of Angular before they get backported to AngularJS. For instance they just added a more lightweight version of ng-repeat which eventually should end up in AngularJS.

Also the Angular team recently shared some insights on what's planned for Angular 2.0. I bet most of those things will first land in Angular.dart before they land in AngularJS.

Christoph
  • 26,519
  • 28
  • 95
  • 133
  • 1
    This statements from a **very** high point of view. I'm aware that this question may not be a perfect fit for SO but there is not very much documentation available for Angular.dart. So I hoped for a little more substantial information like - where does the markup differ (this should not much depend on the language syntax (at least of the most common constructs to get the idea). - what markup constructs are available in the one but not in the other. IMHO that both products are related and are developed by two groups that talk with each other is a bit thin. – Günter Zöchbauer Dec 07 '13 at 21:17
  • To backup the point about 'playground' - http://stackoverflow.com/a/21055757/3966682 – d4nyll Feb 11 '15 at 17:08
16

Update 01/2018

See also What's the difference between Angular 2 TS and Angular 2 Dart?

Update 08/2016

Angular 2 for JS and Dart are now independent projects and will diverge to some degree.

For example the NgModule introduced in TS RC.5 will probably not land in Dart and also the router module will probably not be translated directly. These are changes that were necessary in TS for lazy loading. Dart has an easier lazy loading story and doesn't need many of the changes introduced in Angular2 for TS.

Update

With Angular 2 there are (almost) no differences anymore because Angular.dart and Angular.js are auto-generated from the same TypeScript source. http://techcrunch.com/2015/03/05/microsoft-and-google-collaborate-on-typescript-hell-has-not-frozen-over-yet/

Original

This article lists several differences: ANGULARDART FOR ANGULARJS DEVELOPERS. INTRODUCTION TO THE BEST ANGULAR YET.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567