3 ms·
Coffeescript definitely has some warts. The syntax for functions that take parameters after an anonymous function isn't obvious. In fact the Codeschool.com c
by wmil 13y ago
Coffeescript definitely has some warts. The syntax for functions that take parameters after an anonymous function isn't obvious. In fact the Codeschool.com course gets it wrong. And there have been slight changes to the syntax between versions. I've had to deal with code that broke because of it.
It's still probably a win on the whole, but there's one thing that coffeescript advocates should never do. And they frequently do it.
And that is answering javascript questions with coffeescript. If they want to write Jasmine tests, don't show them coffeescript. If they want an answer on stackoverflow don't give them coffeescript.
Coffeescript is not javascript, and it should never be given unless specifically asked for.
- jashkenas 13y ago> The syntax for functions that take parameters after > an anonymous function isn't obvious. Eh? A function is an argument list (), an arrow ->, and an indented body of code. Putting 'em together: request(url, (response) -> handle response , (error) -> handle error )
- lowboy 13y agoTo be fair, having the comma on the same indentation as the enclosing function call doesn't follow the standard multiline list formatting in comma-last JS.
- jashkenas 13y agoTo be fair, that style works just fine as well, if you prefer it. request url, ((response) -> handle response), (error) -> handle error
- lowboy 13y agoBut then you get into do-you-don't-you with parentheses, which I find is a sticking point for some people when they try CS. I prefer your first example, personally.
- wmil 13y agoThe following are all equivalent: request(url, (response) -> handle response , (error) -> handle error ) request(url, (response) -> handle response (error) -> handle error ) request(url (response) -> handle response (error) -> handle error ) request url, \ (response) -> handle response , (error) -> handle error request url, (response) -> handle response , (error) -> handle error It's very reasonable for a JS developer to be confused when seeing those.
- unquietcode 13y agoIf you can't see what all of these have in common, then you probably shouldn't call yourself a software developer. It's just syntax, people.
- lucisferre 13y agoI'll be the first to admit, I still find it a bit of an awkward syntax, and it was one of the parts of the syntax I kept bumping up against for the longest time. Amazingly I'm finally comfortable with it, but there is a kind of cognitive friction around that one. Personally, I blame whitespace significance. It's hard for whitespace to be both significant to syntax and formatting without impacting one or the other negatively. The principle argument against whitespace significant languages is separation of concerns. Punctuation only for syntax and whitespace only for formatting. That said the benefits of CoffeeScript still outweigh the tradeoffs for me.