CoffeeScript vs ES6?


#1

Should I try my app with CoffeeScript or normally JS and wait for ES6?


#2

coffeescript is closer to the human language than javascript.

I strongly suggest you try it, with the help of a tool like http://js2.coffee/ , also because this way you are learning both javascript and a rudimentary version of python.


#3

Weighing in from the other side, I’d say stick to JS and start using ES6 now. Add a package like https://atmospherejs.com/grigio/babel and use it already.

I used to be in strong favor of coffescript, it seemed easier to read, write, and got rid of “ugly” } ) ; etc. But after revisiting coffeescript code I haven’t seen for months I am now finding it much harder to understand what it is doing. Also a lot of the guides / tutorials / source code from other projects I want to implement are all JS, which starts getting tedious to continually mentally translate or even convert to CS. Now I’m in the process converting the CS I wrote back to JS…

Plus, the “ugly” { } wrappers sometimes actually make it easier to understand what’s going on when there are complicated nested functions with return values, and makes it more clear what your return values are (and when you’re not returning anything).


#4

Very thanks for all reply.
When ES6 release date?


#5

'snt brvty grt? My fngrs lv vdng typng. Cmplnts bt rdblty r vrblwn. Y dnt nd vwls, s why wld y nd brckts?

(Skip to ES6.)


#6

Been using Coffeescript for years, love it except random times when my whitespace gets wacky (like after a copy/paste) then I scream and curse and swear I’ll never use it again.

That said I’ve been recently playing with ES6 (using grigio:babel) and so far love it. It has a lot of the features I love from Coffeescript but it does have it’s own quirks though! Love the new fat arrow functions so I started using them everywhere but you can’t because of Meteor’s use of this. Really wish ES6 had the equivalent of Coffeescript’s thin arrow, there are times you can’t use the fat arrow and have to fall back to using the function keyword:

Template.groupDetail.onCreated(() => {
 this.subscribe('group_detail', this.data.groupId)
})

In that case “this” ends up being Window instead of the Template instance because of lexical scoping of this for fat arrow functions. So you have to use a normal function instead:

Template.groupDetail.onCreated(function() {
 this.subscribe('group_detail', this.data.groupId)
})

Another gotcha with converting from Coffeescript are the implicit returns. Sometimes I’ll have an ES6 function incorrectly return undefined just to find out I was missing the return keyword. Also be careful to always use var or let, Coffeescript lets you omit those but in ES6 you’ll create a global variable. Had a couple bugs I found that came down to that! Overall though I don’t think I’ll go back to Coffeescript.


#7

Coffeescript is something you experiment with in college because everyone else was doing it & then you rewrite your legacy code trying to hide that dark point in your life…


#8

Funny. I like Coffeescript and there are some really great Meteor packages written in it. I have seen the advantage in ES6 over CoffeeScript.

One of the key reasons I like Python is that I can see more code per page. It’s cleaner than most curly based languages and there is less clutter. Many like myself feel a clean organized workspace helps us solve problems faster and feel that Python is a brilliant extension of Feng Shui from the physical space into the meta world.

I write very explicit CoffeeScript and use parenthesis for nearly all method calls. I also write explicit returns. Everything is clear at first glance. So I’m not opposed to parenthesis at all. Yet the myriad of ways in declaring variables, declaring functions, handeling scope within classes, etc. from ES5 are not going away. Also, indentation is good practice and renders curly braces redundant. While CoffeeScript does not have same feeling of “there is one obvious way to do it” like Python, I can still feel like A special agent swinging the Excalibur trained by monks in the high Samurai arts and not like a sloppy College kid experimenting with code on drugs.

The vision for JavaScript now has become making it a brilliant compile target. It will soon have optional explicit type handling. There are entire stacks dedicated to using JavaScript like this. For example, the Volt framework is in Ruby/Opal but node under the hood. Another example is Angular 2 and TypeScript. Indeed, Babel will likely continue to push cutting edge JavaScript before wide adoption. All these validate the compile target principle.

So continue to learn Javascript as it evolves and use CoffeeScript, TypeScript, Ruby, etc. as a preference.


#9

'snt brvty grt? My fngrs lv aveding typng. Cmplnts bt rdblty r vrblwn. Y dnt nd vwls, s why wld y nd brckts?

That’s the English equivalent of LOLCODE.

(start sentence)Isn[single quote]t brevity great(question mark)(end sentence)(start sentence)My fingers love evading typing(end sentence)(start sentence)Complaints about readability are overblown(end sentence)(start sentence)I don[single quote]t need vowels(sentence separator) so why would I need brackets(question mark)(end sentence)

That’s the equivalent of Javascript.

Isn’t brevity great? My fingers love evading typing. Complaints about readability are overblown. I don’t need vowels, so why would I need brackets?

That’s Coffeescript.


#10

I’ve been using coffee for a while (3 years); going to switch to ES6 going forward (as it contains most features of coffee that I rely on without the bad stuff) and maybe use TypeScript for very large projects that would benefit from more static analysis.

Also, you can start using ES6 now; no need to wait.


#11

Is there any good converter from coffeescript to es6?


#13

Funnily enough, if you replace CoffeeScript to ES6 in this article, all the arguments will remain valid and some will get even more adequate, like the “you don’t think in ES6”.


#14

but not all ES6 features can be transpiled to JS and Coffee cannot have any.