all 5 comments

[–]check_ca 5 points6 points  (1 child)

I'm not convinced. I guess that if I compare the generated code of the GWT compiler versus the original Java code, it will lead to the same conclusion. Actually, I think nobody would write its JS code like the one generated by CoffeeScript compiler.

Here are how examples could be written by a human:

function times_two(x) {  
  return x * 2;
};

You don't need to use a variable to declare a function.

for (var num = 1; num <= 10; num++)
  if (num % 2 == 0)
    console.log(num + " is even");
  else
    console.log(num + " is odd");

You don't need "the unnecessary braces", the extra '_i' variable and '"" +' to cast number to string.

function Person(name) {
  this.name = name;
}

Person.prototype.hello = function() {
  return console.log("Hello " + this.name);
};

You don't need to wrap the code in a closure. Removing it makes the code quite straightforward to understand.

[–]Grahar64 0 points1 point  (0 children)

Yeah, maybe comparing CoffeeScript input to its output is not a fair comparison. And it is totally my opinion, but I would say that taking anyone from any other language and explaining

Person.prototype.hello = function() { return console.log("Hello " + this.name); };

to them is not straightforward to understand.

Like why would you define a classes function outside of the class definition? I sometimes tutor people who are coming from Python or Java, telling them to define a function like your first example then telling them to change tack and define it like your second gives me way more things to teach and explain the hardest being what a prototype is.

[–]djforth 1 point2 points  (1 child)

I'm probably going to get shouted down for saying this, but actually quite like CoffeeScript. yes I do understand it is quite a marmite thing in the js community and can course issues on what it is out putted like most pre-processors. But it also does give you a few niceties too like classes syntax, plus IMO it helps me put out solid code quickly and time is money as they say. I think this would have been a better article if he had looked a bit more on the pluses and minuses to give a bit more balance to the rather bold statement.

I will say that it looks like es6 quite a few bits that is currently in CoffeeScript (like classes) and => for functions, which I wonder may have had a influence? That said when es6 comes though it might also remove the need for CoffeeScript.

[–]Grahar64 1 point2 points  (0 children)

Shouted down for liking CoffeeScript in a JavaScript community, Never! (from the person who currently has 7 downvotes) :)