-
Notifications
You must be signed in to change notification settings - Fork 2k
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
FAQs: es6 roadmap, choosing an implementation, tooling #4078
Comments
Cheers. |
Thanks. If you can clarify a bit, I'll submit a PR for the FAQ page. Feel free to ignore one or more of the points if you don't have time for this. Specifically:
|
|
I’m tired of reading how CoffeeScript is obsolete now that ES2015 is here to save us. I use CoffeeScript for the syntax, not the features that ES2015 has been busy catching up to, and the day I stop using CoffeeScript will be the day it’s pried out of my cold dead curly braces. I am worried, though, that as time goes on and more people learn ES2015, I’ll have a harder time convincing teams and bosses to use CoffeeScript. There’s currently barely a mention of ES2015 in the readme or on coffeescript.org, and too many people assume that the project is dead and will slip into obsolescence as ES2015 gets more widely adopted. At the very least, there needs to be a prominent section in the readme and at coffeescript.org explaining CoffeeScript’s relation to ES2015, especially why CoffeeScript is still relevant today and will continue to be relevant when ES2016 and ES2017 and so on arrive. What I tell skeptics is that I expect CoffeeScript to continue to mature along with JavaScript, and when new versions of JavaScript reach wide adoption CoffeeScript will simply compile down to whatever the new target is, when there is a performance or readability benefit to doing so. I tell people that they should think of CoffeeScript as primarily an alternate syntax for JavaScript, one that prevents stupid bugs through things like significant whitespace and the I see defenses of CoffeeScript in this new ES2015 era that go along the lines of, well currently both ES2015 and CoffeeScript need to be transpiled down to ES5 or ES3, and that will be the case for many years, so what’s the difference? And by the time Microsoft Edge is the oldest IE we need to support, CoffeeScript will (presumably) compile down to ES2015, so there’s nothing to worry about. But this neglects two moderately large use cases where big chunks of ES2015 are usable today, without transpiling, thanks to the growing support already present in Chrome:
I don’t know what, if any, performance benefits anyone gets from letting Node 4 use native ES2015 features rather than the compiled-to-ES5 replacements, but presumably someone somewhere will claim that they must have ES2015-native code running in their Node app, or their app will suffer mightily, and therefore the app can’t be coded in CoffeeScript. Or ditto for a private Chrome-only app. And the thing is, they might be right. At the very least, it will be easier to debug such apps if the fat arrow compiles to a fat arrow, etc. So besides updating the docs, which I feel like is the bare minimum response that ES2015 requires, we should perhaps discuss some future CoffeeScript that compiles at least some features to ES2015. Perhaps this could be a non-default feature enabled by argument, e.g. |
I just started work on a site generator type thing. The tool is V8 only, so thought I'd be lazy and give ES6 a go. I had about 30 lines of JS written when I switched to CoffeeScript. It was like switching from Klingon to French. |
(as a french one, I can guarantee we still have some pretty weird rules :P) |
Looks like ES6 support might be happening, jashkenas has offered commit access to Decaf author (Decaf is CoffeeScript that transpiles to ES6). |
Hey folks, @juliankrispel. Julian emailed me back, but I'll respond here, so as to leave it in public. I just thought that since there's rightly a lot of interest in having CoffeeScript target ES6 instead of ES3, and Julian was actually doing something about it, and he attracted the interest of known solid contributors like @lydell and @eventualbuddha, it might have a higher chance of success getting done in a branch over here with a little more attention available to it. That said, if anyone — new contributors or old — wants to experiment or play around in an "es6" branch, go nuts. I'd imagine you'd start behind a |
That'd be a huge boost to the project @jashkenaz! Thanks! What do I do now? :) Julian Krispel-Samsel
|
hmm, i’d say:
|
If I could just offer one suggestion: keep in mind the destinations for this generated code. In broad terms, they are:
I suppose the easiest approach for now is to set a target of ES2015, and let Babel handle converting that down to ES5 for all three destinations. It would be nice, though, if we could somehow get ES2015 or mostly-ES2015 code for cases 2 and 3, so that the code we debug with is closer to the original CoffeeScript (i.e. with fat arrows preserved, etc.). Maybe that’s a challenge for Babel rather than CoffeeScript, assuming that Babel will need to be part of the pipeline until ES2015 support is complete in Node and in whatever browsers your app is designed to support. At the very least we should probably call the flag |
I would actually prefer not to compile to ES6 syntax where we have an ES3 syntax that works as well or better. For example, there's no reason to compile to What I'd like to focus on is only those cases where we can't compile to something usable in the three cases that @GeoffreyBooth listed above, and to cases where the ES6 equivalent really is incompatible with features included today. At the end of this road, it should be easy to write canonical code using pretty much every currently-popular framework/environment, while being better and more fun to use than vanilla JS. If the focus is on the differences, rather than trying to create a complete target to ES6, then I would hope that it would be less total work to do. |
no matter what route we take, in the end there should be an ES2015 (which is as close to idiomatic, hand-written JS as possible) and an ES3 output (with the same semantics as the current output) |
It’s easy to get carried away when thinking about what to compile CoffeeScript to (at least that’s my experience) :) I’d say that we do things in small steps. Let’s start with the most important one: I also agree with @bjmiller that I see no point in compiling to |
you’re already talking about which features the ES2015 compile target should be implemented first. i talked about how we have to change the current code to have a second compile target at all. if we simply say “we don’t introduce a second compile target and selectively start compiling some features to their ES2015 equivalents”, i think this will go down in flames. people will be annoyed that their mobile phone from 2008 can’t handle those features and say that it’s mission critical for their job to have another way would be a |
As for things like compiling |
Actually I'd just like to talk about putting decaf into coffeescript first. For any who don't know: This decoupled relationship is possible because coffeescript, like any great modular program, exposes functionality that can be used outside of itself (lexer, parser and compiler). Modularity is a good thing for so many reasons that I'm not going to elaborate on right now but for that reason I'd prefer decaf to maintain a separate repo, possibly inside a 'coffeescript' github organisation. Anybody with me here? @jashkenas would be great to get an answer from you on that. |
Oh, I didn't realize that was your approach @juliankrispel! Awesome! Now all I can say is: Continue on that path! 👍 |
@juliankrispel sure, and this fits well with my idea here: decaf would be an alternative renderer to the default one, and the default one would be included in CS. and to use decaf, you’d do: import decaf from 'decafjs'
import {parse} from 'coffee-script'
const es3 = parse('a -> b').convert()
const es2015 = parse('a -> b').convert(decaf) |
@flying-sheep I'm 100% with you on that one. I've started to implement this, will be sharing it soon :) |
@juliankrispel If you would like to move the juliankrispel/decaf repo to the coffeescript organisation, I can help you with that. We should have moved this repo (jashkenas/coffeescript) there long ago. |
As folks may know, Modules have two parts: the ECMA import/export es6 syntax/semantics, and the WHATWG browser module loading. This has created a mess in the current es6 world with webpack, browserify, common vs amd, bundling, and way, way more. It makes it a bit hard to use our modules, and babel can only do half the job because of the ECMA/WHATWG split. There are two ways to minimize the hassle for using/testing Modules ourselves:
|
Hi @backspaces, I think your comment points to a big design decision that needs to be made: when CoffeeScript supports ES2015 modules, is that support limited to simply outputting ES2015 JavaScript (and then Babel or I was assuming with my Though without |
Sorry to be late. Yes: modules are somewhat independent of the JS version in that So I see no harm in allowing JS5 or JS3 code using the DOM loading spec, I ran a simple experiment for the simplest possible use of System.js, see a I believe it is possible to have System.js do this for you w/o any Even this will go away as soon as <script type="module" ...> is completed -- Owen On Fri, Feb 5, 2016 at 11:24 PM, Geoffrey Booth [email protected]
|
@GeoffreyBooth agreed. I would just leave coffeescript simply as an producer of (a) javascript (version). So why not just decouple the ES3 output and module-loaders into a separate modules?
Not sure if the modularity/size-topic has been touched yet, but how about versioning the 'coffee-script' package which depends on the current lowest denominator (es3? es2015?)
Same will happen with ES6/ES7/ESwhatever. It's about time @jashkenas is going to publish a manifesto article to tell people on how coffeescript does not focus on compatibility with any idea out there.
Without an manifesto, people are more likely to not adopt coffeescript because it seems nothing more than |
I think splitting out CoffeeScript into multiple npm packages will be a nightmare to manage. The same can be achieved by passing options to the CoffeeScript compiler. There's already a bunch of options defined, we would just be adding more (one more, if my suggestion is adopted: There seems to be a lot of confusion about whether CoffeeScript module support means that CoffeeScript is resolving all the modules itself the way Babel does, and still outputting ES5; or if the intent is for CoffeeScript to simply output ES2015-standard Some discussion of CoffeeScript's future, posted prominently on coffeescript.org, is long overdue. I feel like “manifesto” might be a bit strong, but the website should have some statement acknowledging ES2015 and JavaScript’s continued development and CoffeeScript’s place alongside it. |
I guess a good question might be: till which degree is coffeescript a serverside runtime (RT) and/or a code generation tool (CG). Personally my RT/CG ratio is 70/30.
Could you elaborate on that? Because I agree with you from the point of one maintainer, but not from the point of an opensource community. |
@coderofsalvation, I think multiple NPM packages will be an issue for frameworks and plugins that incorporate CoffeeScript downstream. Think of Meteor and its Is this where we’re going to discuss the plans for how CoffeeScript should support modules? Perhaps that discussion should get its own room somewhere? #3162 seems a bit full. @michaelficarra and @backspaces, I welcome suggestions. @juliankrispel, I’d love to hear how Decaf fits into modules and ES2015 (perhaps in a new room as well). To hopefully start to wrap up the broader “how to handle ES2015” discussion, though, here’s my proposal:
|
I don't like the idea of Coffeescript being multiple packages or becoming yet another transpiler. In my opinion, the best possible route (aka what I wish existed today) was CoffeeScript 2.0, a breaking version that targets ES6 and relies on proper build chains or browser support. Meanwhile, CoffeeScript 1.x can remain stable and occasionally updated as needed as the ES3/compat version. Modern tooling is already enough of a mess. CoffeeScript should continue to be a very straightforward tool. You use CoffeeScript 2.0 if you are looking towards the future and let current build systems sort out the resulting JS dreaming of the day when you don't actually need Babel or Traceur or whatever because browser support finally arrives. You use CoffeeScript 1.x if you don't want to deal with that mess and just target ES3 with the limitations that brings. CS2 would (in my opinion) output ES6 code whenever possible vs CS1 shims. Classes would also now compile to ES6 classes and not CS classes (breaking change, but major version increment). 99% of the stuff would stay the same and people who wanted could spend some time porting what needs to be ported if they feel like the upgrade benefits their project. As the years go by and more breaking features require implementation, you just release new major versions. No one has to use them and the old ones will exist forever. |
I totally agree with @samuelhorwitz - we need a new, shiny, breaking, ES6-only version 2 of the beloved Coffeescript. Or maybe version 3, since The Brave New WorldCoffeScript Version 6, should have initially these 3 main Goals :
The Bad NewsUnfortunately, the word in town as of mid-2016 is And talking about about coffeescript 2 / redux, makes old coffeescript enthousiasts like me wanna weep. From CTOs, to senior developers and juniors, they all think aloud the same:
And I can't blame them. I can't really convince anyone to pick coffeescript, not even myself. Unfortunately, I use it only for small non-persistent experiments these days... and I really miss it. Cause at work, like many people reading this, I have to deal with the ugliness of
I would absolutely adore to be able to use ALL of the ES6 features that are available now or in the future (transpiler or native), but using the beloved syntax. I strongly believe its the only way forwards, to keep coffeescript alive, relevant & thriving! PS: Maybe @jashkenas, or someone else nominated, should start & lead a Kickstarter / IndyGoGo / etc campaign to fund really well the project, and work on it full time. I 'm sure the project will attract loads of support, 10x or 100x more that what redux did. Best regards. |
Yeah, that's all true, but we're really just talking about creating a new language based on CoffeeScript. That's been done loads of times. If you want to take another run at it, great, but to be honest, just explaining how you think someone else should proceed isn't that helpful. You make a lot of intelligent points, but if anyone was up for creating a new CoffeeScript based language with ES6 features, they would've already done it. It's fairly easy to write a parser, and the language design, the JS code generators with source mapping, the users, the libraries and the docs already exist for the most part. We only need a working prototype on GitHub, and people can start contributing... |
That's what I am calling for :-) Sure, the technical capacity exists, but my point is to give this idea some momentum and make it a cause! I dream of motivating the community, to collectivelly make a kickstarter or something and get this baby going. Of course the best that can call for this cause (not necessarily implement it all) is @jashkenas and other main contributors like @michaelficarra and others. |
@samuelhorwitz @anodynos @carlsmith Let's make this happen. I've created a "CoffeeScript6" org on github with a "discuss" repo: https://github.com/coffeescript6/discuss I propose we move the conversation to issues & PR's there and start sketching out how this can work. |
@juliankrispel has come far with https://github.com/rainforestapp/decaf. Same goes for @eventualbuddha's https://github.com/decaffeinate/decaffeinate |
Thanks @carlmathisen - both decaf & decaffeinate are very useful to start with. Lets ignore they both make mistakes, they are both at infancy i.e in class Animal extends Lifeform
#varLocalToClass = 1 # fails to transpile
aPrototypeProperty: 'value' # wrong intepretation
instanceMethod: (arg1, @storeInThis, splat...) -> 'returnValue' # OK becomes class Animal extends Lifeform {
//varLocalToClass = 1 // fails to transpile with
// "expected a colon between the key and expression of a class property"
aPrototypeProperty = 'value'; // wrong intepretation,
// Its not a local variable but a prototype property.
// Also it isn't actually valid ES6, local variables inside a class aren't allowed.
instanceMethod(arg1, storeInThis, ...splat) { this.storeInThis = storeInThis; return 'returnValue'; } // OK
} If I am not wrong, both don't aim to become transpilers of all existing of CoffeeScript@1 for production ES6 code, but instead as a tool to one-off migrate from coffeescript -> ES6, with some (or a lot of) manual intervention. We actually aim to keep people using CoffeeScript! And plain existing CoffeeScript should transpile OK to ES6 97% of the time, using the new shiny CoffeeScript6 transpiler. But enough with the existing coffeescript. The most important objective for us now should be to create the new language, namely CoffeeScript@6, a new near-superset of CoffeeScript@1, but with enabling all the nice ES6 features and not caring anymore about targeting ES3!. The last part is partially done by /decaf.*/. Creating a new coffeescript@6, we have a long way to go! |
I would like to see Coffee ES6 happen. As I see it, once you go Coffee it is hard to go back. Similar to HAML, once you start to code in HAML, HTML looks soo ugly and bloated, you will never choose it unless you have to. Of all developers I learned/forced to use HAML or Coffee, all use HAML today for server side rendering and all that must to use JS syntax in bigger teams, usually do it with sadness in their eyes. If new Coffee parser happens, I it is possible that it could catch old steam and became popular again. |
+1 can we pleaseee make this happen! as @dux said |
And the point of x = undefined # set here so `let` does not occur in the loop
for y in z
x = y if someCondition()
break It also is more work to try and find these optimisations. Right now the first line is not required as The only thing I want to see is maybe generated ESwhatever classes for native extension. I would support having a separate keyword for exactly that. The way 'classes' are built in a traditional manner now works fine for everyone. We are missing a few keywords, but this breaks compatibility, so I see a need for command line flags (or first/last comment in the file that specifies that flags like a modeline). Other than that, what are we really missing? Maybe I am a little old school, but I am just not seeing how compiling to ES* as much as possible is going to provide any benefit, especially in the browser world. And if you have to transpile with Babel, what is the point? We already have valid ES3 code and some new features like generators (without silly |
When CoffeeScript was created, we wrote cross-browser programs, so it made sense for the language to compile to cross-browser JavaScript. Today, JavaScript is used more widely, and often in projects that only need support for the latest version of V8 or some other modern engine, so it makes sense to compile to ES6, and use tools like Babel to support older browsers. That just fits into what everybody does these days, and it separates concerns. The existing compiler compiles ES6 features to ES6, so for example, you need Babel to use CoffeeScript generators on older browsers already. The direction seems to have naturally shifted implicitly towards a compiler that only outputs ES6, that uses Babel to convert it to ES5 or ES3 if you need to. CoffeeScript classes are not fully compatible with ES6 classes, so we no longer have complete interop with JavaScript libraries. Fixing that will break a lot of existing CoffeeScript code. CoffeeScript may slowly evolve to emit modern JS, with compiler flags for breaking changes like classes, or someone may write a new ES6 focussed compiler from scratch, and drop backwards compatibility entirely, but something has to happen, as always compiling CoffeeScript directly to ES3 has become a bad idea. |
@andrew: really nice point. Hadn't thought of that. Sigh.
I hope CS figures out the tough road ahead into es6 land, it isn't easy.
And modules are such a bitch, with the tug of war between TC39 and whatwg.
What a mistake that was!
Even tho my project has converted from CS to es6 for the framework, I want
a CS user-facing front end. Mainly because it is like the prior agent based
modeling system we used, java based: NetLogo. Logo users have preferred CS
to JS in the past and CS avoids The Bad Parts as well as being elegant and
pythonic.
Look at Pencil Code for what I mean. http://pencilcode.net/ Sweet!
…-- Owen
|
I'm doing research prior to adopting Coffeescript for a young startup's codebase. After intensive googling, I found no clear answers but many people asking themselves the same questions, so it may be a good idea to amend the FAQ with answers to these:
jslint
?coffeelint
? Anything else different from what you'd use with vanilla JS?Thanks.
A discussion we had today on IRC:
The text was updated successfully, but these errors were encountered: