21 comments

[ 3.9 ms ] story [ 51.6 ms ] thread
or use a language/environment that allows for trailing commas...
This really is the sensible solution.
Seriously! Every language should support this. Not just for arrays but in argument lists too! Python does a good job here but I can't think of anything else which does.
Hint hint: PHP does this!
Depending on other syntax facets, that can create ambiguity.

Does that trailing comma represent nothing (the end of the list) or an undefined/null/empty/whatever item (an extra item adding to the length of the list?

Even if the meaning is completely unambiguous as far as the language is concerned, that doesn't necessarily make it intuitive to humans especially in a mixed language scenario.

perl allows both trailing commas and also optional list-quoting which breaks on whitespace (commas unneeded):

    my @stuff = (
      "foo",
      "bar",
      "baz",
    );
or:

    my @stuff = qw(
      foo
      bar
      baz
    );
or

  my @stuff = qw(foo bar baz);
TIMTOWDI indeed...
You only have to edit one line to add an element to the list!!!

Who says you have to add your elements at the end? If OP is going to be so rude and absolutist, he should really pick a stronger argument.

The real benefit of comma-first-style is that it becomes immediately apparent while editing the code that something is missing when you forget a comma.
The argument from elegance would be stronger if they lined up braces, too:

    var a = ["stuff"
            ,"whatever"
            ,"extra"
            ,"more"
            ,"other"
            ,"things"
            ];
(I already posted this reply on his blog, but seems like it has been deleted along with a bunch of other disagreeing comments there)

What if you want to add a new element at the top? And even when you need to add it at the end, if you use a decent editor, it won't make a difference. For example, with vim:

(Place cursor on last element) A,<cr>myNewElement

As opposed to left comma style: o,<space>myNewElement

Only 3 extra keysrokes for both cases. (<cr> is the Enter key, by the way)

I can't believe this kind of post could make it to the front page of Hacker News.

I can't believe this kind of post could make it to the front page of Hacker News.

Personally, I think it's the creative use of "Dink-butt".

I didn't delete any comments. I looked an your horribly horribly wrong and misguided comment is there.
Since so many people don't get it. My above comment is a joke. You actually do make some very strong arguments and I appreciate the discussion.
Cache because the website cannot establish a database connection:

http://webcache.googleusercontent.com/search?q=cache:http://...

Also, what a gratuitously obnoxious post. Flagged as inappropriate.

Oh come on! Have a sense of humor. I couldn't have made this post more tongue-in-cheek!

I took a really small code-formatting issue and turned it into a faux holy war using faulty logic, cherry-picked facts, and doofy ad hominem attacks in the tradition of Bloom County:

http://www.berkeleybreathed.com/pages/09bloomlibrary.asp

My post might be "gratuitously obnoxious," but your taking offense at it is amusingly pretentious.

I didn't get that this was a joke. It's my fault, I read the first few lines and thought that you were serious and that it was a waste of time to continue reading. I actually came here to write, "this must be a joke."
I think you just invoked some variant of Poe's law. Or well, I suppose you invoked Poe's law as applied to flamewars as fundamentalism.
Comma-related, grammar irony: "Put Your Commas on the Left, Dink-Butt"
I always hated that the top element is shifted over one char when people put the commas on the left. I don't find it "clean" at all. All items lined up evenly on the left with commas on the right looks way better to me.
This is a great example of how some people will jettison good taste in favor of some pointless metric or supposed problem.