My eyes were a little scarred at first, but now we are seeing the reasoning behind it:
Note how the errors pop out in the comma-first style.
The object literal cases will throw, though a final trailing comma will cause errors in MSIE. The missing comma errors are particularly devious when it comes to the var statement, and lists of arrays.
Many decry comma-first as being “ugly” or “unclean”. However, this is a statement about one’s brain and habituation, not about the code itself. In my opinion, “clean” is defined as “easier to interpret quickly”. If a given coding convention makes differences look different (especially errors) and another coding convention makes errors harder to spot, then it’s clear that the first is more “clean”. If you disagree, then apparently, “clean” just means “looks like what I saw yesterday and the day before”. This rubric is worse than useless, as it specifically prevents innovation or improvement.
And, regarding “ugly”… ALL code is ugly. Yours, mine, everyone’s. Code Is Ugly. Just face it. When someone says “beautiful code”, hear “beautiful rotten entrails”. The only beautiful code, the most clean code, is no code at all. If it’s there, it’s ugly. The unfortunate fact of software development is that, in order to create beautiful software, we must use ugly code.
The best we can do is make sure that there’s as little code as absolutely necessary, and that it is as reliable and easy to interpret as possible. Conventions must be judged based on these standards. Anything that obscures the intent of the software is by definition “unclean”, and every line of code is “ugly”.
The comment discusses the code below:
What do you think? I am always amazed at how ridged I am with some style, and how I can flip around on others. One random example. I used to very much be a guy who liked the CSS of
style="foo: bar; fuz: buz;" but now
style="foo:bar; fuz:buz" tickles my fancy.