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
Coffeescript to ES6 #492
Comments
That might be a good idea. Been thinking about it too. Wanna take a stab at it? |
I'd be really happy to start the migration to ES6 (hopefully fixing the memory issues). What about the build step? Do you prefer grunt or do we want to switch to gulp? |
I have no preference with regard to build tools, as long as we are able to generate the same build outputs. |
You'll likely be disappointed about the memory effect of converting the code to use ES6. It's not like CoffeeScript code would inherently use more memory as you can compile it to JS. Similar refactorings that might lead to lower memory consumption could be applied to the CoffeeScript source as well. There's even one gotcha in ES6 if you use the arrow syntax for functions as it automatically binds to Of course, if you run ES6 natively (node?), more optimisations might be applied. For other reasons ES6 does sound promising 👍 |
@lautis migrating a library like Baconjs to es6 is quite a big task but if it doesn't help improving the memory issue it's just wasted time for me, I would step back suggesting a code refactor. |
I wouldn't call it wasted time. You'd definitely have a lot deeper understanding how Bacon could be optimised. However, that would require a bit more than doing a mechanical transformation. At least to me this seems like a hard way to improve memory usage. If you find CoffeeScript incomprehensible, the pure JS codebase might be more pleasant to work with. A quick way to get the JS migration done, would be to take the compiled JS output and clean the worst CoffeeScript idiosyncrasies. |
have you guys an irc channel? May we discuss deeper about that in a chat? https://gitter.im/? |
Ok then, let's try the Gitter chat... h |
@lautis 6to5 doesn't bind functions to |
There's also a CoffeeScript to ES6 transpiler on the 6to5 roadmap but I can't say for sure when that'll be available, definently some time in the near future though. |
+1 for a rewrite to ES6/ES5, or even vanilla JS + sweet.js macros. |
I have checked the Baconjs generated from coffeescript and the other one coming from my migration/es6 fork. Here you can run the benchmark by yourself http://jsperf.com/bacon-coffeescript-vs-bacon-es6 and check the results |
With Node 0.10 performance seems pretty badly reduced on the ES6 branch, but Node 0.10 based on quite old Chrome. Replacing |
@lautis That benchmark is incorrect since |
I changed the link to point to a later revision that seems to be a bit less wrong. |
Ok I will update the branch using replacing the native bind functions to get faster performances also on Chrome |
@lautis changing the native bind to the wrapped one the es6 branch is a bit faster than the master. I hope that with my next updates, splitting the source code into smaller modules it will become also a bit more readable. |
I am sorry guys but I must give up migrating Baconjs to es6.
I learned a lot reading the Baconjs source code but I've also understood that a project like Rxjs fits more to my needs. |
That's factually incorrect. 6to5 has actually become less reliant on polyfill and shim methods. The output code has been coming less and less verbose and with features such as loose mode that outputs simpler and faster code but is less spec compliant I take extreme issue with those kind of statements. There are only a few features that require |
@sebmck don't you think that for something simple like: // es6
for (var item of array) {
//...
} an output like this (+ a huge Symbol polyfill ) : // 6to5 output
for (var _iterator = array[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
var item = _step.value;
} is a bit too much?
|
Hey @GianlucaGuarini, I can imagine why that would be frustrating. However, it needs to be the compiled 6to5 output in order to properly follow the ES6 specification. This isn't a stability issue, it's by design. We've been looking into how people can opt-in to a simpler output which ignores various parts of the spec. This is what @sebmck meant by loose mode, and it's likely what you are looking for. |
@GianlucaGuarini ES6 |
@sebmck |
@GianlucaGuarini that's unfortunate 😿 (and understandable, porting over patches isn't exactly the most exciting job). We'll need to be more focused if we want to get this done. |
That would only work when we know a value is an array literal. function(items) {
for (let item of items) {
// no way of knowing items is an array.
}
} |
We can't keep track of types unless they're inlined as literals.
It's been present since the inclusion of the for of transformer. See babel/babel@b0cfbb2. As I said before, 6to5 has ways to facilitate the inclusion of these methods and native types without polluting the global scope with a polyfill. See the FAQ and coreAliasing. |
Let's see if the |
Here is working PoC: #526 |
Oups sorry :D then probably I have imagined that BTW It's clear that 6to5 it's an awesome tool, but I am not sure in this case It can compete against the clear and dry coffeescript source code used for the Baconjs library |
@GianlucaGuarini By default, definently. Loose mode however will be better, if not equivalently fast. EDIT fixed a link |
looking forward to try it out thanks for your support |
Closing for now, until some progress seen, if any... |
What do you think if we move the project forward migrating the current coffeescript code to javascript next? I think we could transpile it using https://6to5.github.io/
The text was updated successfully, but these errors were encountered: