Skip to content

Instantly share code, notes, and snippets.

View binbrain's full-sized avatar

Jim Pharis binbrain

View GitHub Profile
@benjie
benjie / CoffeeScriptReasons.md
Last active November 4, 2016 15:43
Reasons CoffeeScript is still relevant for me

I'm often asked why I still use CoffeeScript rather than ES6/7. Well, in truth I use both, but I do still prefer CoffeeScript for the following reasons:

  • Correctly trimmed multiline strings (ES6 includes the indentation because it doesn't have significant whitespace)
  • Existential operator (a?.b; b?(); a?.b?() and of course a ? b)
    • a ? b is more appropriate than a || b if "" or 0 are values of a you wish to persist
    • (a && a.b && typeof a.b === 'function') ? a.b() : undefined doesn't quite have the same ring to it as a?.b?()
  • Significant whitespace
    • (a personal preference, but since you already lay your code out sensibly why do you need the additional visual distraction of braces?)
  • Convenient shorthand for common things (-> (regular non-bound function), @ (this.), :: (.prototype.))
  • in to check if something in a list