3 ms·
I have to admit that I'm resisting CoffeeScript. It looks interesting but for me it seems like just an extra step for something that isn't bothering me. I'd r
by jakejake 15y ago
I have to admit that I'm resisting CoffeeScript. It looks interesting but for me it seems like just an extra step for something that isn't bothering me. I'd rather write code that's a little more verbose than to have to "remote control" it via another syntax. Am I missing the boat?
- MatthewPhillips 15y agoNot really. It's not usually mentioned but CoffeeScript loses a lot of its supposed elegance when you try to do things like chaining. Especially chaining a function that takes a function as an argument. To achieve better looking chaining you'll talk yourself into not using anonymous functions. tldr: whitespace significant languages do not do chaining very elegantly. Other than that CoffeeScript is pretty cool.
- jashkenas 15y ago... not so much. A big part of the point of having a minimal function literal, `->` instead of `function(){}`, is that using anonymous functions is a bit more pleasant in any context -- including chaining. list.map((num) -> num * 2 ).map((doubled) -> doubled + 5 ) ... instead of: list.map(function(num) { return num * 2; }).map(function(doubled) { return doubled + 5; }); It's not a huge difference. But, by the same token, it's certainly not a reason to avoid the use of anonymous functions.
- MatthewPhillips 15y agoCoffeeScript is always going to be less verbose than JavaScript, but in the context of a full code file having some functions with parentheses and some without isn't a pleasant consistent experience in my book. Another thing CoffeeScript handles unelegantly is two anonymous functions (very common when a function needs an onsuccess and an onerror): api.get( -> # Success here. -> # Failure here. ) The benefit of curlies is you get a consistent experience and don't have to go to Stackoverflow to find out when you need commas or parentheses and when you don't.