1. 16
  1.  

  2. 2

    According to whom has CoffeeScript served its purpose?

    1. 3

      A lot of the good features in Coffeescript like fat arrows made it in to ES6

      1. 2

        Three major features certainly made it into ES6:

        1. Fat Arrow => for declaring an anonymous function with scope context preservation
        2. String interpolation.
        3. Splats and destructuring.

        But that’s not the extent of CoffeeScript’s ergonomic improvements (in no particular order):

        • Everything is an expression. I love this the most about Ruby/Rust/Elm/etc. No need for explicit return keyword (in most cases, except when wanting to short circuit). The last “expression” in a function is automatically returned as its return value.

        • ? to guard against possible undefined keys when doing nested object access (e.g. val = obj.?key.?might.?not.?exist will not crash. In JS you’d have to guard against every level of object access via if (obj && obj.key && obj.key.might && obj.key.might.not)

        • -> skinny arrow to not preserve scope context when declaring an anonymous function. In legitimate cases where you want a closure’s this (or @ syntactic sugar in CoffeeScript) to actually refer to the new anonymous function scope’s this or arguments, you don’t want to use a =>. In vanilla JS, that means writing out function(), in CoffeeScript, it’s a skinny arrow.

        • Not requiring parenthesis for function calls (e.g. alert "Hey ma, no parenths!").

        • Control flow expressions can be suffixed to a line (e.g. alert "You should see this if..." if truthy_value).

        • List Interpretation syntax for loops (Python-esque).

        1. 1

          Try this in ES6:

          alert `Hey ma, no parenths!`
          

          (Tagged template literals + coercion from Array to String, har har har.)