4

Judging by the ES6 compatibility table foundhere

Most shims and transpilers only implement below 70% of ES6 features, so why should someone use Babel/Traceur when Javascript ES6 is pretty much supported now in Chrome/Safari and Firefox by default.

I mean, if I was a developer at say Babel - surely it would be your number 1 priority to make sure you have ES6 and even ES7 features implemented before your competition.

Or am I missing something here?

Paleo
  • 21,831
  • 4
  • 65
  • 76
Daniel Cooke
  • 1,426
  • 12
  • 22
  • 1
    TypeScript is a superset of JavaScript. If it's valid JavaScript, it's valid TypeScript as long as the compiler has been informed of any new syntax. All ES6 features are valid in TypeScript. – Mike Cluck Feb 07 '17 at 17:12
  • Already answered here: http://stackoverflow.com/q/12694530/2902660 – Pineda Feb 07 '17 at 17:12
  • @Pineda - I was in the midst of editting my question - maybe have a read and try answering again? – Daniel Cooke Feb 07 '17 at 17:17
  • @JaredSmith read again and get back to me – Daniel Cooke Feb 07 '17 at 17:17
  • @DanielCooke TypeScript adds some extra syntax and a type system to JS. Otherwise, it's just JS. Babel allows you to use features which are not yet supported in all browsers by compiling your code into a supported format. – Mike Cluck Feb 07 '17 at 17:18
  • Have you read the link to the duplicate? – Pineda Feb 07 '17 at 17:18
  • @Pineda I did yes, I understand that TS compiles to JS, but now that most features have been implemented by the browser - I guess what I'm asking is - is there any point of using shims/transpilers anymore? – Daniel Cooke Feb 07 '17 at 17:20
  • 4
    @DanielCooke: Typescript isn't merely a transpiler for browser compatibility. But even if it was, then wouldn't the reason be fairly obvious? Don't transpilers exist to support legacy implementations? If you don't need to support legacy browsers, then clearly you wouldn't need to transpile your code. But if you do, then you would. But again, Typescript is so much more than that. –  Feb 07 '17 at 17:21
  • 1
    @DanielCooke your edit changed nothing. Again: how much flexibility are you willing to lose in the name of safety? Are you willing to wait for new features until they can be fit into the static type system so you know they're type-safe (typescript) or do you have to have them ASAP (babel)? There's no hard and fast answer to that question (and by extension your question). – Jared Smith Feb 07 '17 at 17:21
  • You say you read it but have no mention of this feature: _"(Typescript) primarily provides optional static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code."_ – Pineda Feb 07 '17 at 17:22
  • (I edited to update the tags.) – Paleo Feb 07 '17 at 17:23
  • 1
    Thanks everyone.. I guess. I didn't consider the reason transpilers are used is to support legacy browsers. That is the answer I needed. – Daniel Cooke Feb 07 '17 at 17:24
  • @Pineda Again I will say - I understand the benefits of using Typescript - I forgot that ES6 does not define Types (and other useful static analysis implementations) so this question is no longer about Typescript if you would read my edit. – Daniel Cooke Feb 07 '17 at 17:27
  • 2
    @squint Thank you - this is the answer I was looking for. Kind of a shambles here, my bad. But thanks anyway. (cut me some slack people I'm young) – Daniel Cooke Feb 07 '17 at 17:30
  • 1
    @DanielCooke: Don't sweat it if you get roughed up a little here. It's all just tough love! –  Feb 07 '17 at 17:37
  • This has been sufficiently edited for a reopening and removal of downvotes. – Crono Jan 04 '19 at 02:10

2 Answers2

4

Most shims and transpilers only implement below 70% of ES6 features, so why should someone use Babel/Traceur when Javascript ES6 is pretty much supported now in Chrome/Safari and Firefox by default.

Because some of my applications still need to support down to IE9 (we finally got your client to raise the bar to IE9). And it's not because of the lack of knowledge due to our client, it's because the users of that platform actually use this Browser.

Especially when your users are companies (or their employees) IE (not even Edge) is often still the standard.

"am I missing something here?" -Yes. You are missing decades of arguments about the relative merits of dynamic and static typing. Get to reading. – Jared Smith

@Daniel, none of your edits does change anything at this point made by Jared.

JS will probably never provide static type checking or compile time errors; because this is a substantially different approach to writing and publishing code.

I mean, if I was a developer at say Babel - surely it would be your number 1 priority to make sure you have ES6 and even ES7 features implemented before your competition.

Yes, I like using ES6 and use a transpiler when I need to, but I still consider ES7 features as unstable and work in progress. If the final implementation will differ from the current version I'd have to revisit and check every project I would have used it on. That's too much uncertainty to actually use them in production, so ...
I (as one of Babels's users) actually don't care wether one transpiler or the other already supports these latest features, unless there's a final standard published.

Although sometimes I like playing around with these new features and take like to take a look at their benefits, possibilities, limits and problems, and how to transpile them into current code.

Thomas
  • 11,958
  • 1
  • 14
  • 23
  • We still support IE 9 too (and we were supporting IE 8 until a year ago). – apokryfos Feb 07 '17 at 17:47
  • 2
    *"I still consider ES7 features as unstable and work in progress"* Mmh. ES7 (ES2016) was released last year. It is done, there is nothing in progress anymore. – Felix Kling Feb 07 '17 at 20:03
3

In general, transpilers exist to convert code written for one environment to code written for a different environment. This can be done for converting code between entirely different languages, or merely between different versions of a language.

So early on when ECMAScript 6 was new and the browsers didn't support much or any of it, there were transpilers developed to let you use ECMAScript's new language features in browsers that only supported the "legacy" ECMAScript features.

Even though the newest browsers now support most or all of the new features, little has changed. You'd still use a transpiler to support those same previous implementations that didn't support those features.

At some point, a developer may drop support for certain browsers, which would mean that at that point they could stop transpiling the code. This decision is going to be made differently by different individuals, and so the transpilers will continue to be used for years to come.