Should I use Traceur instead of Typescript to target ES5 but be ready for ES6

StackOverflow https://stackoverflow.com/questions/23658752

  •  22-07-2023
  •  | 
  •  

Вопрос

I'm working on a large code base that could benefit from Typescript, but since eventually the world will be moving to ES6, should I steer the development towards Traceur?

I don't want to change Typescript implementations in order to target ES6 (when is ready), so my feeling now is to go ahead with Traceur.

Can anyone advise?

Это было полезно?

Решение

I definitely do not agree with the opinion that TypeScript and Traceur are so different, TypeScript is ES5 with types and Traceur is just about ES6.

On the one hand there is an ES6 compatible TypeScript 2.0 in progress. On the other hand there are a couple of features in Traceur marked as experimental in docs, namely types and annotations. And it turns out that types are very similar to the TypeScript types whereas annotations are something irrelevant both to ES6 and TypeScript. So Traceur is more just ES6 and there is already name for that: AtScript. Yes, we have another language extension :-)

There is a nice slide from Miško Hevery presentation that shows what is really going on here, fully valid as soon as TypeScript 2.0 is released:

AtScript and TypeScript as ES6 extensions

So whatever you decide to use, it is important to note: they are subsets, you may write ES5/ES6 JS and it will be valid TypeScript code, you may write TypeScript and it will be valid AtScript code.

Turning back to your question, I would give the humble advise to start with ES6 using Traceur with experimental features turned off (it is pretty stable now) and extend as needed, because this is not so radical a decision, doesn't lock you in and leaves space to move in the future.

UPD: At the beginning of the 2015 I would also recommend to pay attention to 6to5 project (renamed to Babel) as an alternative to Traceur. It moves very fast and provides has some nice features, such as readability of generated code and better support for node.js and build systems.

Другие советы

TypeScript and Traceur have completely different goals and aren’t comparable in the way you are trying to compare them.

TypeScript is a superset of EcmaScript that adds strict typing. It includes some features from ES6, but its primary goal is to add strict typing to the language (while aligning with ES6), not to provide ES6 support.

In contrast, Traceur is a future-EcmaScript to current-EcmaScript compiler. It doesn’t add anything to the language that isn’t already proposed for the next version of EcmaScript.

If you just want to write EcmaScript 6 today, use Traceur. If you want optional strict typing and all the benefits that go along with that, plus some ES6 features, use TypeScript.

FYI the next version (2.0) of typescript in development is focused on ES6 compatibility : http://typescript.codeplex.com/wikipage?title=Roadmap

Updated post here:

http://blogs.msdn.com/b/typescript/archive/2014/10/22/typescript-and-the-road-to-2-0.aspx

From TypeScript 1.5 to TypeScript 2.0

As we look to the 2.0 release, we 're focusing on two goals in addition to our main goal of bringing good tooling to JavaScript development. The first is to align with ES6. Aligning with ES6 allows TypeScript to become a superset of the next JavaScript, opening the way for working with new code patterns like destructuring, string templates, promises, iterators and more in addition to features TypeScript already supports, such as classes and lambda functions. We're also working with the Flow and Angular teams to make sure that TypeScript is the best language for working with a broader range of libraries, including declarative frameworks like the upcoming Angular 2.0 release.

I would definitely recommend going the ES6 route.

For anyone else landing on this question, go and check out tagtree's videos on ES6 features.

To see template strings, arrow syntax and desctructuring, have a look at this free tagtree tutorial screencast, no registration is required.

for a large scale system I would definitely recommend going with typescript.

when u have a team working together typescript will give you all the benefits of modern computer language with es6 compatibility(based on microsoft roadmap) but with the strict typing and code completion benefits.

Both Traceur and Typescript transpiles have very similar features, with some pros and cons.

I believe that the main questions to be answered, analyzed and compared more deeply are: "Who are its proponents?" and "What is the historic of every one of them?".

Q1: Well, both are big and reputable companies with large investment in technology, workforce to give future to their transpiles. Google is behind the Traceur and Microsoft is behind Typescript.

Q2.1: Google has a history as a strong supporter of open source frameworks such as Chromium (the open source browser base of Google Chrome) and thousands of free APIs available, almost all based on open standards. The Traceur follows this same logic adopting guidelines of ECMAScript 6 specification, anticipating it and ensuring its compatibility in future revisions.

Q2.2: Microsoft has a history of encompass standards and extend them proprietary, creating dependence on customers in their platform and not respecting a shared vision of standardization of other market players. The main objective of Typescript is compatibilize the other compilers on the market with the syntax and features of your JScript.NET compiler, not with the ECMAScript 6. Any mention of ECMA is just "sugar for ants".

The realtime typed parsing and the advanced code completion of Typescript are a considerable advantage for small projects, but larger projects need to take a right decision during the architecture definition, otherwise the entire project could be compromised by a compiler outdated or discontinued and out of standards, depending on an unique vendor.

However, many features of ECMAScript 6 are just implemented on the Firefox 33 and Chrome 38 current versions (in 2014-10).

http://kangax.github.io/compat-table/es6/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top