Yep, I get the preference over a lang that can't do trailing commas, which is why I used the trailing comma style as the counter-example. In a compile-to-JS language it's hopefully possible to make trailing commas legal. They've been legal in JavaScript itself for a long time (ES5) [0]
> Also, it is much easier to look at this [...] and see if all the commas are actually present.
ESLint can trivially lint that you haven't missed a comma (including the final trailing comma). The style guide/ESLint config I use (Airbnb's) enforces trailing commas. If ESLint can do it, Elm should be able to.
They might have been technically legal since ES5, but they were only finalised this year (ES2017, with function params), and still don't seem to have full support. I've been burned a few times by that: I know that MDN article cited says they are, but code with trailing commas (esp objects) breaks in eg IE without transpilation
Yeah as the article says they were only added for object literals in ES5, which is the main place the 'issue' comes up, and where I was making the comparison to Elm. That works in IE > ~7/8? without transpilation.
> In a compile-to-JS language it's hopefully possible to make trailing commas legal. They've been legal in JavaScript itself for a long time
Well, Elm is not trying to be JS, it's trying to be better, and there's really no reason to need trailing commas. I'd even argue that it argue it leaves a message of mixed intent "did the author want to continue the list?" and needlessly enables duplicate styles for the same one thing.
That's a tenuous argument. I've yet to meet a developer who thinks a trailing comma is the slightest bit ambiguous when the next character is a closing bracket.
> Also, it is much easier to look at this [...] and see if all the commas are actually present.
ESLint can trivially lint that you haven't missed a comma (including the final trailing comma). The style guide/ESLint config I use (Airbnb's) enforces trailing commas. If ESLint can do it, Elm should be able to.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...