AngularJS 2 - 使用哪种语言? (打字稿,Javascript,Dart) [英] AngularJS 2 - Which language to use? (Typescript, Javascript, Dart)

查看:285
本文介绍了AngularJS 2 - 使用哪种语言? (打字稿,Javascript,Dart)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用AngularJS 2时,文档建议使用三种语言:
Typescript Javascript Dart



我只用于Javascript EcmaScript 5,我想知道这些的强度和弱点三个?



在问这个问题的时候,文档是更加开发Typescript和漂亮苗条的其他人(甚至他们自己的语言Dart):




  • 打字机: 4教程,16个开发人员指南,4个测试指南

  • JavaScript: 0教程,4开发人员指南,0测试指南

  • Dart: >


我应该改变我使用Javascript开发的习惯,并遵循Angular 2使用Typescript建议的习惯吗?是否真的改变了Javascript的概念?



AngularJS 2.0 官方网站

解决方案

Dart易于启动,因为您需要的一切都是由Darts生态系统提供的一方面(语言,包管理,构建,...)。



TypeScript



TS有最多的资源..),因为有庞大的用户群。



Angular的 Dart和 JS版本是从TS生成的。

似乎有很多问题,以获得一个Angular + TS项目启动和运行(见Angular2问题在这里SO),但有种子项目可用,一切已经建立。我不知道细节,因为我只使用Dart自己。



对于TS,现在有 Angular CLI ,它通过TypeScript为Angular2改善了很多开发者体验。



JavaScript ,ES5,ES6



如果你是一个JS纯粹主义者,它可能是适合你的语言。如果没有(如果你是你可能不会问这个问题),那么我相信你最好使用Dart或TS。
Angular使用类型注释在几个方面。对于JS,需要解决方法,否则一个简单的类型注释就足够了(主要是依赖注入)。



Dart

Dart是一个很好的语言,有一组工具在一起工作。
很多问题的JS / TS环境原因解决了优雅的Dart。



自2016/5/20左右Angular2 Dart是一个独立的项目,




  • 在TS中多次更换的路由器模块使其与离线模板编译工作,在Dart中没有被替换,因为在Dart延迟加载也可以与老路由器正常工作。


  • 。 。


  • 新的Forms模块已经被引入到Dart中,因此 NgModule


  • Dart从头开始离线模板编译,但不支持浏览器平台动态


  • 一个新的依赖注入模块似乎正在进行中,Dart基于Dagger2(目前尚不可用)替换DI


  • Angular2 Dart非常注重构建输出大小和运行时性能,但AFAIK支持多平台支持像服务器端渲染)。



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

解决方案

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.

这篇关于AngularJS 2 - 使用哪种语言? (打字稿,Javascript,Dart)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆