Hacker News new | ask | show | jobs
by arckiearc 5391 days ago
I'm curious, would you prefer to write code like this over the explicit version?

  foo bar: 'baz', quux('onoz')
Or are you just concerned about inconsistencies?

I like not having to specify parentheses, but only do so when it's immediately obvious to a reader of the code what the result of the statement will be.

1 comments

My concern (as something thinking about trying coffeescript) is that it takes me quite a lot of mental effort to parse that, and at the moment the compiler seem to have trouble with it. I'm wondering if it practice it becomes more natural as time progresses.
Much of your difficulty/effort is due to lack of familiarity. The rule is basically if you see an identifier followed by a space, it's a function call that ends with the line, outdent, or postfix control flow statement. An identifier followed by a colon means an object literal.

I have no more trouble recognizing these patterns than distinguishing between function calls and parens being used for grouping. Part of that is due to my own enthusiastic syntax highlighting for vim [1] that leaves identifiers as pretty much the only piece of text not highlighted. If you take a look at that file, the syntax in it is very old and comes from when : was the assignment operator which was dropped when implicit object literals were introduced.

[1] http://gr.ayre.st/s/vim/coffeescript_example.html