-
Notifications
You must be signed in to change notification settings - Fork 569
ES6 time #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why? This was previously discussed in #320, with the conclusion at the time:
Is there performance, or any other benefit, to be gained by switching to ES6? |
Here is my analysis: Gopher.js can be used theoretically for roughly 4 types of projects:
|
Nice analysis. I think the key comes down to one point, though:
What is your source for this claim? Yes, ES6 offers some syntax optimizations that make human-written code shorter, but I don't expect most of this will affect the type of generated code produces by GopherJS (although I may be wrong, and would be happy to be proven wrong). As for the speed of ES6, I don't think it's true that, on average, ES6 is faster. This resource shows that some specific operations are faster, others are slower. Most have no change at all. Is there any reason to think that it would actually benefit GopherJS for performance? |
I haven't got benchmarks but I can only assume the syntax optimisations for human-writability must translate to at least equal to an approach where a human wrote an equivalent code in ES5 and at best faster due to the JS engine able to make optimisations in a lower-level language such as assembly. It's just a guess. I also assume that if a gap does exist (on aggregate), this gap will intuitively only get wider in favour of ES6. |
They are definitely slightly smaller. In my own projects, I have seen that in every case. Here is one of my examples: https://github.com/thehonestscoop/gutter See the ES5 and ES6 non-minified distribution files. |
@flimzy The benchmarks link you provided above says: |
ES6 has generators. It can be used to implement goroutines in a much less verbose way. This link shows the difference (in verbosity) between ES6 and ES5 implementing generators. |
GopherJS has more pressing issues for now (like #989 and friends), but a here are a few thoughts for future:
|
For another point in favour of ES6, see this comment in the related issue: We cannot make code splitting work, and webpack also spits out warnings such as
Our dev team has been wrestling with this for days already (with no result yet). If the output would be ES6, it would work much easier with webpack. |
@benma if you could file this as a separate issue with a minimal reproduction example for this warning along with the expected/observed behavior, it would be a lot easier for us to investigate possible solutions that require less than grand architectural redesigns :) FWIW, according to our survey results, only ~9% of users are targeting ES5 specifically, so perhaps embracing ES2015 features is becoming a sensible step. |
@nevkontakte It turned out that this warning did not impact code splitting - that now works but the warning still remains. The warning goes away is I replace |
I think it's a good time to have another go at this discussion. To that end, I created a new proposal, which declares that ES 2015 features can be used in GopherJS-generated code and formalizes the principles for using newer APIs in future: #1121. If anyone has opinions in favor or against, I would appreciate you taking time to share them in the new issue. |
It's probably about (or fast approaching) time for gopher.js to produce ES6 javascript files.
For those that still require ES5, I can write up an instructions on transpiling for these combinations:
ES5 => babel
ES5 + minify => babel + uglify
ES6 + minify => babel-minify
I won't have the expertise to convert gopher.js to produce ES6 code.
The text was updated successfully, but these errors were encountered: