I would add them, but formatter removes them after that. So while I would prefer to have trailing commas (but only in multiline expressions) I stopped using them as that is what code formatter expects.
So there unfortunately is no option for me in this survey
I don’t add them unless the formatter adds them for me. That’s the case for the Javascript stuff I work on and not for the Elixir stuff. When I had to manually added them, I actually felt like I ended up doing more work. Now that formatters add/remove them for me, I don’t care that much. The smaller diff is only slightly compelling to me.
Another +1 to adding trailing commas on multi-line lists/maps/etc… I always prefer them, diff’s, moving, etc… are always cleaner, but the formatter for some reason thinks more noisy diffs are more useful for reasons that I don’t understand… ^.^;
Funnily enough, in Elm the formatter is the one who usually rewrites my trailing commas to leading commas.
Actually, it would be nice if the formatter could get an option to keep trailing commas alone (and potentially add them to lists that span multiple lines automatically), although personally I do not have a very strong opinion about this issue at all.
In case of the single line functions it really doesn’t make sense to write foo(a, b,) over foo(a, b), but in multiline function calls it became quite handful, as:
foo(
a,
b,
)
IMHO looks more consistent than:
foo(
a,
b
)
And also it result s in cleaner in diffs in tools like Git and is easier for tools like Darcs/Pijul (which operates on on diffs/graggles).
I like not having an extra thing in mind while editing configs/deps or whatnot so personally I find trailing commas lovely. Sadly, the formatter disagrees.
No trailing comma’s on single lines, it’s for multiple lines only, like this is fine:
[1, 2, 3, 4]
But this would be weird:
[1, 2, 3, 4, ]
However for multiple lines:
[
1,
2,
3,
4,
]
That means that you can add and remove (potentially long) elements with a minimal git diff, you can rearrange without worrying about adding/removing comma’s, etc… etc… It all ‘just works’.
Lol, well in ML languages no commas is Application, so that would be ambiguous (How would you handle [blah 1 2 3 4], where do the arguments to blah end and the list begin or do more things apply to the return value of blah/N or…?), in Elixir it would be more possible on an initial though but I don’t doubt there are ambiguous things around that too. ^.^