Live data from Hacker News

Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

news.ycombinator.com

11–20 of 62 posts

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#11
post #2

Presumably you mean in the browser, rather than node.js? When you can compile and use polyfills with babel and webpack, then why not?

Babel and webpack make debugging with the v8 debugger a nightmare. How do you approach that and avoid using console.log everywhere? console.log can be great and 90% of the time it's enough but for that other 10% I'd rather my debugging observe the execution context instead of being part of it.

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#12
I'm going to use Typescript regardless of which flavor of ES/JS I expect to target, for type safety alone. Since I'm already using a build system, writing for the latest ES/JS spec supported by Typescript is entirely about convenience of the new specs themselves. I can use Typescript to downlevel as necessary for the expected runtime environments.

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#13
post #11
post #2

Presumably you mean in the browser, rather than node.js? When you can compile and use polyfills with babel and webpack, then why not?

Babel and webpack make debugging with the v8 debugger a nightmare. How do you approach that and avoid using console.log everywhere? console.log can be great and 90% of the time it's enough but for that other 10% I'd rather my debugging observe the execution context instead of being part of it.

As long as sourcemaps are setup correctly it's not bad at all.

That being said, setting up sourcemaps correctly can be a bear... But it's taken most of the pain away from our debugging issues.

And if that's not possible, as long as you aren't using some of the "heavy to transpile" features like async/await, looking at the translated code directly (and stepping through it) is generally close enough to get the gist of what's going on.

Edit: the bigger headache for me is code which loses it's full stack-trace, which is becoming more and more common when transpiling async/await for reasons I haven't had time to look into.

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#14
post #11
post #2

Presumably you mean in the browser, rather than node.js? When you can compile and use polyfills with babel and webpack, then why not?

Babel and webpack make debugging with the v8 debugger a nightmare. How do you approach that and avoid using console.log everywhere? console.log can be great and 90% of the time it's enough but for that other 10% I'd rather my debugging observe the execution context instead of being part of it.

Isn't this what SourceMaps are for?

Edit: What he said /\

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#15
Broken windows theory- ES6 code is more elegant to look at, which encourages people to write prettier code.

Working on a team of experienced non-browser devs, ES6 syntax allowed them to take the language seriously and actually try to do the right thing rather than 'commit atrocities of Javascript' (actual statement).

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#16
post #11
post #2

Presumably you mean in the browser, rather than node.js? When you can compile and use polyfills with babel and webpack, then why not?

Babel and webpack make debugging with the v8 debugger a nightmare. How do you approach that and avoid using console.log everywhere? console.log can be great and 90% of the time it's enough but for that other 10% I'd rather my debugging observe the execution context instead of being part of it.

In addition to sourcemaps, another option that I've been meaning to try is to skip most of the babel transforms for typical development builds. Chrome has had full ES2015 support for a while now and it looks like it now has async/await on stable, so it's getting to a point where it should be possible to just debug your ES2015/ES2016/whatever code within Chrome without needing source maps.

You'd still need to do some transpiling for imports/exports and JSX, though, depending on what you use. And running different code in development and production has its risks.

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#18
In a nutshell, the js community is doing a great job of moving the language forward, and there is a great deal of cost to be borne by using the oldest version of the language that all browsers support. Browser vendors (in general) are the laggards, but there is an easy enough way to work around them.

ES6 also nudges the code toward a bit more uniformity that can lead to better medium term maintainability.

Re: Ask HN: If you targetting ES6 by default, how did you rationalize that choice?

#20
post #11

Earlier quoted context omitted.

Babel and webpack make debugging with the v8 debugger a nightmare. How do you approach that and avoid using console.log everywhere? console.log can be great and 90% of the time it's enough but for that other 10% I'd rather my debugging observe the execution context instead of being part of it.

In addition to sourcemaps, another option that I've been meaning to try is to skip most of the babel transforms for typical development builds. Chrome has had full ES2015 support for a while now and it looks like it now has async/await on stable, so it's getting to a point where it should be possible to just debug your ES2015/ES2016/whatever code within Chrome without needing source maps. You'd still need to do some…

(I feel like i'm all over this thread...)

I actually tried this for a bit. I found that it really increased the complexity of the build system for not that much of a gain.

Instead of having a "dev" build and a "prod" build, we needed a "chromeDev", a "otherBrowsersDev", and a "prod" build.

So now you have 3 separate environments for your babel configs which you need to keep in-sync, and you run the risk of the semantics being slightly different natively vs the transpiled version (Which IMO isn't that bad when you go from transpiled->native as the transpiled is normally a subset of the "native" functionality, so you are less likely to hit issues)

Post reply on HN