Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is nice. There are too many gotchas to remember in JavaScript; better to let a liberal compiler translate something nice into the "machine code" that works in all browsers.

(Personally, I always write:

   something = {
       foo: "bar",
       bar: "baz",
   }
which works in Firefox, but not IE. A compiler would not be upset when it omits that extra trailing comma. Of course, you can always write:

    something = { foo: "bar"
                , bar: "baz"
                }
But let's face it, that is only not ugly in Haskell.)


Which is why CoffeeScript lets you leave commas out of multiline object and array literals (for those that didn't see catch it in there):

    something: {
      foo: "bar"
      bar: "baz"
    }


If the second form works and avoids bugs, can't you train your eyes to accept it?

That's what I did in SQL a few years ago, and I can't count how many times it has helped me since.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: