Why I Don't Use CoffeeScript

CoffeeScript in of itself, and not as a transpiled language, is admittedly pretty. The problem for me is what it's supposedly "fixing".

Syntax Sugar

For a Rails and Python developer JavaScript is ugly, or so I hear. You have... (ready for it?), curly brackets and white space that doesn't mean anything. But, I like my whitespace. Most JavaScript engineers I know do. I like not being restricted on how I write my code aesthetically. Not to mention CoffeeScript is by far less human readable than JavaScript. Programming languages, in my opinion, need to be a good balance of both human and machine readable. Simple example:

cube = (x) -> square(x) * x
cube = function(x) {
  return square(x) * x;
};

Even if you've never programmed before the 2nd example would make sense. The first is, well, illegible. I guess if you were writing 1000s of lines of code every single day from top to bottom typing less would be important, but we're humans, not computers, so legibility is far more important than saving a few keystrokes. When talking to mostly rails people I've heard numerous times that they dislike having to type out "function". Yes. This is a reason I hear as a plus for CoffeeScript. That is pure fucking laziness in my opinion and it really makes it hard for me to take their opinions seriously after.

But, more than all of this what bugs me is the fact it's a completely transpiled language mostly for syntax sugar. What an awful reason. So, on to the next reason...

Related: http://oscargodson.com/posts/writing-eloquent-javascript-without-coffeescript.html

Wart Removal

Another thing people always bring up is that it fixes "warts" in JavaScript. Things like for...in loops and they give examples like this:

for (var key in obj) {
  if (obj.hasOwnProperty(key)) { // only look at direct properties
    var value = obj[key];
    // do stuff...
  }
}

First of all... no. Just use a for(i=0;i<=10;i++), but if you need to use for...ins a lot, write a helper function that takes care of the hasOwnProperty() check. You need an entirely different language for it? Or, the other day someone on Google+ said that he likes CoffeeScript because he didn't like that JavaScript made vars global when you forgot the var keyword and that it was "just wrong". Protip: Don't do that. Just don't, not write var. Problem solved.

There are many other examples I've seen and they're all like this. That's just trying to prove a point. I find wart removal to be an awful selling point. In other words you're saying Fuck the need to learn how to write JavaScript, we'll fix it for ya. You really need a transpiled language to save you some time from learning the right way to write JavaScript in the first place? Learn JavaScript's pain points and just don't do them.

It's like that C/C++ quote goes:

"In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg." Bjarne Stroustrup.

Classes

I hear a lot about the love of how CoffeeScript handles classes and writing classes is a pain in JavaScript. You know why? Because, JavaScript is a fucking prototypal language.

However, for whatever reason, people have a primal urge to use "classes" in JavaScript. Luckily there's numerous small libraries to try to shim classes into JavaScript. You don't need an entire transpiled language for it. For example here's what you can do with a pretty tiny script:

var Ninja = Person.extend({
  init: function(){
    this._super( false );
  },
  dance: function(){
    // Call the inherited version of dance()
    return this._super();
  },
  swingSword: function(){
    return true;
  }
});

From: http://ejohn.org/blog/simple-javascript-inheritance/

Let me remind you though, JavaScript is not a classical language. Here's a famous quote from Crockford from http://www.crockford.com/javascript/inheritance.html:

I have been writing JavaScript for 8 years now, and I have never once found need to use an uber function. The super idea is fairly important in the classical pattern, but it appears to be unnecessary in the prototypal and functional patterns. I now see my early attempts to support the classical model in JavaScript as a mistake. Douglas Crockford

Conclusion

After everything, CoffeeScript is for people who hate JavaScript. JavaScript warts should be avoided by education and understanding of the core language, not by simply ignoring them and cool features like how CoffeeScript handles Classes, or even loops, can easily be fixed with a much smaller codebase with no need to compile by using a simple homebrewed library or something like underscore.js, jQuery, etc.

P.S. People who write CoffeeScript specific codebases/libraries/etc and name them like "mylib.js"... i hate you. *cough*batman.js*cough*