Details
-
Documentation
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
None
-
None
-
None
Description
The Groovy Style Guide mentions that parentheses can be omitted (not always, I know). And that's it. I think the primary purpose of a style guide is to define a good set of recommendations for coding practices, rather than list all the available options. (Because that's like good old Perl: you can write the same thing in so many ways, since the syntax is so lenient, which then practically doomed the language.) So the style guide that is supposed to give us answers, is still leaving us with questions right now.
I would like to know what you recommend: should we omit parentheses or not? I am really puzzled, because:
- IntelliJ IDEA can suggest auto-removal of unnecessary parentheses.
- I think Gradle started with not using parentheses but now it mixes up styles: https://github.com/gradle/gradle/issues/10307
- The Internet kinda started making up their own style guides, and it is not the first time I see that they actually recommend the parentheses for readability: https://books.google.hu/books?id=7Hc5DwAAQBAJ&lpg=PA347&ots=I5irALxRRu&dq=groovy%20code%20style%20parentheses&hl=hu&pg=PA347#v=onepage&q=groovy%20code%20style%20parentheses&f=false
- Whereas, for DSLs, the target audience may not know programming so well, so the parentheses are not recommended: https://books.google.hu/books?id=RNtOCwAAQBAJ&lpg=PA16&ots=xEOKCWi0xo&dq=groovy%20code%20style%20parentheses&hl=hu&pg=PA16#v=onepage&q=groovy%20code%20style%20parentheses&f=false
But this still puzzles me.
- Are missing parentheses really that hard to read? If someone with no programming skills can read statements without them better, than how come the opposite is true for an advanced programmer?
- Should the no-parentheses style be suggested only for DSLs? That would include Gradle too, right?
Thanks in advance.