Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That’s not really the opposite opinion… the opposite is not allowing trailing commas (like JSON) so if you remove the last item from a list, you need to adjust the line above as well. And when you add something to a list, you need to know if something will come after it, even though you don’t necessarily know.

Commas as separator is pretty much orthogonal, and… well, better overall.



I got what they were saying. My point is that if you have a line feed then a comma is an entirely redundant piece of syntax. Commas should only be needed if you are placing multiple statements on a single line. Just like how several programming languages treat semi-colons (eg Go, bash, JavaScript, etc). So mandating them is the opposite of that modern languages should be insisting upon.

In Murex (my own language) both commas and semi-colons can be dropped if the statement or expression is terminated by a line feed.

    list = %[
        chair
        table
        “bed-side table”
    ]
YAML, for all of its warts, also behaves similarly too.

It’s a much better way to handle lists and objects because the comma only exists for the same reason the semi-colon does in C-like syntax: as a parser hint. But if you’ve got a new line then that hint is completely redundant.


Would your language also accept this?

  list = %[
    chair, table
  ]
And this?

  list = %[
    chair, table,
  ]


Yes it would:

    » %[ chair, table ]
    [
        "chair",
        "table"
    ]

    » %[ chair, table, ]
    [
        "chair",
        "table"
    ]
Here you can see that internally it understands you're writing a JSON object however it relaxes the semantics a little (without going full on YAML) because chasing that erroneous comma is probably the least fun part of programming.


So, accepting the spurious comma at the end of the list and not requiring commas when there's a newline can coexist. I would say they are tho orthogonal properties. You can support the latter without opposing the former.


Sure, but that’s not what the linked article discusses. It specifically states that commas are mandatory on each line. Not that the rule for commas is relaxed. And what I’m arguing is that requiring commas on each line is pushing the syntax in the wrong direction.


Clearly, whether the language considers commas necessary or optional should be in a config file.


It's only redundant in languages that make it redundant, like you mentioned C at the end - it's the new line that's redundant there (or only for readability), it's the semicolon with the 'end' semantics.


> It's only redundant in languages that make it redundant

Yeah, I did say "several" not "all".

There is very little benefit in new languages making terminator tokens necessary when followed by LF. We are long past the point of needing to optimise language syntax for parser efficiency.


In this specific case it's not redundant in C - without the commas, the strings would be merged together.


Exactly, that's what I said? 'In this specific case' though? It would be news to me (not that I've used it since university!) that they're ever non-semantic?




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: