Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS 2 - Which language to use? (Typescript, Javascript, Dart) [closed]

With AngularJS 2 coming out, the documentation is suggesting three languages : Typescript, Javascript and Dart.

I'm only used to Javascript EcmaScript 5 and am wondering what are the strength and weakness of these three ?

At the time this question is asked, the documentation is more developed on Typescript and pretty slim on the others (even their own language Dart):

  • Typescript: 4 Tutorials, 16 Developer Guides, 4 Testing Guides
  • Javascript: 0 Tutorials, 4 Developer Guides, 0 Testing Guides
  • Dart: 0 Tutorials, 14 Developer Guides, 0 Testing guides

Should I change my habit of developing using Javascript and follow what Angular 2 is suggesting by using Typescript ? Does it really change the concepts of Javascript ?

AngularJS 2.0 official website

like image 393
Elfayer Avatar asked Feb 01 '16 11:02

Elfayer


People also ask

Does AngularJS use TypeScript or JavaScript?

Since angularjs is a JavaScript framework, it works naturally. There are definitely typed files that were made for angular as you can see here. P.s. Angular2 was built on Typescript.

Is Angular 2 JavaScript or TypeScript?

AngularJS is by far the most popular JavaScript framework available today for creating web applications. And now Angular 2 and TypeScript are bringing true object oriented web development to the mainstream, in a syntax that is strikingly close to Java 8.

Which language can be used to write Angular 2 code?

Angular 2 itself is built using TypeScript.

Does Angular JS use TypeScript?

Angular is a modern framework built entirely in TypeScript, and as a result, using TypeScript with Angular provides a seamless experience. The Angular documentation not only supports TypeScript as a first-class citizen, but uses it as its primary language.


1 Answers

Dart makes it easy to start because everything you need is provided by the Darts ecosystem out of one hand (language, package management, build, ...).

TypeScript

For TS there are the most resources available (documentation, ...) because there is a huge user base.

The Dart and JS version of Angular is generated from TS.
There seem to be lots of issues to get a Angular+TS project up and running (see Angular2 questions here on SO) but there are seed projects available where everything is set up already. I don't know details because I'm using only Dart myself.

For TS there is now Angular CLI which improves the developer experience a lot for Angular2 with TypeScript.

JavaScript, ES5, ES6

If you're a JS purist, it might be the right language for you. If not (if you were you probably wouldn't ask this question) then I'm quite sure you're better off using Dart or TS. Angular makes use of type annotations in several ways. With JS there are "workarounds" needed, where otherwise a simple type annotation is enough (mostly dependency injection).

Dart

Dart is a nice language with a set of tools that work well together. A lot of issues the JS/TS environment causes are solved elegantly for Dart.

Since about 2016/05 Angular2 Dart is an independent project and differs quite a lot from the TS and JS versions (as of 2016/10).

  • The Router module that was replaced in TS several times to make it work with offline template compilation, wasn't replaced in Dart because in Dart lazy loading also works fine with the "old" router.

  • ... and also NgModule wasn't introduced to Dart for the same reason.

  • The new Forms module built for TS wasn't ported (yet) to Dart.

  • Dart had offline template compilation from the beginning but doesn't support the browser-platform-dynamic to compile components at runtime.

  • A new Dependency Injection module seems to be work in progress for Dart based on Dagger2 (currently not yet available) to replace the DI system that was auto-generated from TypeScript code.

  • Angular2 Dart has a strong focus on build output size and runtime performance but AFAIK support for multi-platform support (like server-side rendering) was dropped.

like image 120
Günter Zöchbauer Avatar answered Sep 27 '22 18:09

Günter Zöchbauer