3 ms·
> CoffeeScript makes parentheses optional in many cases (as does Ruby) This is one thing that really annoys me with Coffeescript. I personally find the lack of
by olalonde 14y ago
> CoffeeScript makes parentheses optional in many cases (as does Ruby)
This is one thing that really annoys me with Coffeescript. I personally find the lack of parentheses makes the code harder to read (since it's sometimes ambiguous where the parentheses should be) but faster to write.
> An important consequence of this is implicit returns: because every construct must return a value, all functions must return a value, whether return is called explicitly or not.
Same concern here. When working with someone else's code, it is sometimes unclear if the author intended the last expression to be the return value or it just happened to be the last line of code and it is safe to return something else.
The lack of parentheses and implicit returns also makes it hard to maintain a consistent code style guide as there are too many ways of writing the same thing.
- jfb 14y agoI'm really not a fan of these optional syntactic elements -- I don't find that they aid comprehension. It's like optional braces in C; I get the idea -- reduce conceptual overhead, make the intent of the code clear -- but in practice, it's just nasty. I wonder if this is why I like scheme, or if scheme is why I like simple syntax.
- jashkenas 14y ago> I personally find the lack of parentheses makes the code > harder to read [...] but faster to write. Then simply use parentheses. They're still there for you to rely on as much as you'd like to. One main reason why they're optional is so that things flow together nicely with the significant whitespace, like so: filter list, (item) -> if item.flag is 'priority' item.visible else false ... writing the above with all parentheses present wouldn't be quite as nice -- and I don't think any clearer to read.