I find the trailing commas convenient for the mult...
# codingconventions
d
I find the trailing commas convenient for the multi-line declarations, but also a bit strange on method calls. I wonder if they are commonly used (👍 for yes, 👎 for no), and in which cases https://twitter.com/dankim/status/1367602098985201671
👎 2
👍 13
c
I really don’t like it. it makes code harder to read, and syntax should always be optimized for reading over writing,
m
I think it's a great feature for multiline expressions/declarations. I don't understand the argument about worse readability - at least in my experience there is no difference in that.
âž• 4
c
for me it looks just wrong, maybe it needs time to get used to it (but actually i hope it just goes aways)
the next step is to “optimize” the String.join method, it can be written much simpler if it adds a comma at the end too
🙄 2
🤦 2
r
Imho, trailing commas should be used in every multiline expression (by this I mean expressions like "parameter-per-line" and maybe "JSON-like" expressions). Yes, they look weird in single line expressions, or in "X parameters, 2 lines" expressions I see used often in Java calling expressions - I agree you shouldn't use them there. But that's not the case with the expression types I listed - you control the "end of parameter/element" by new lines, and "end of whole expression" by indentation, so impact to readability is nil (as those are way more prominent features of the code), but it makes great advancements to writing - changing order + git diffs. (no idea about the code generation, really that's a weak argument)
Oh and it also makes easier to refactor/write stuff using multiple cursors
❤️ 1
c
looks a bit like space vs tabs, so i guess in the end it will just be hidden by good ides and diff tools
computers are way better at adding and removing that comma to please everybody than humans
r
like I understand spaces vs tabs fight, cause there are no real good arguments either way, just basically habit... But I haven't heard any argument than "looks weird" against trailing commas (and plenty for), and I bet you that 90%+ peoples for em, really mean in in the line-by-line/json-like expressions as I said, since yes, they are useless in other types.
m
At first I hated them, by now I love them 🙂
same 3
Just not in
when
expressions, they tend to look awkward with the sole arrow on the next line. But I’ll go with it for consistency.
âž• 1
Sometimes I re-order parameters/arguments and get a compile error because some code wasn’t using a trailing comma yet.