Live data from Hacker News

A modest proposal

happyassassin.net

11–20 of 189 posts

Re: A modest proposal

#11

Yes, please! This applies to many other lists as well, not only restricted to JSON. Besides, imagine a world of Java, Javascript, C-like anything, where you would be DISALLOWED to have a semicolon after the last statement in a block. Crazy thought, right?

Commas are unnecessary. There is zero benefit to having them. The code is actually easier to parse if you just remove them from the rules list entirely. No commas might look weird for a day or so, but you quickly get used to it.

(I'm ignoring the comma operator, which is a special case and not relevant to the main point.)

Re: A modest proposal

#13

Yes, please! This applies to many other lists as well, not only restricted to JSON. Besides, imagine a world of Java, Javascript, C-like anything, where you would be DISALLOWED to have a semicolon after the last statement in a block. Crazy thought, right?

In Rust, omitting the last semicolon in a block indicates an implicit return of the final expression of the block.

Re: A modest proposal

#15
I would love to have trailing commas in JSON but I can see that being JSON something too widely extended over the internet it's not possible to do it for real as it will break all around. So, what I do is to have my editor to fix this issue as I'm completely unable to stop doing it :-)

Re: A modest proposal

#17
Actually, in the JSON grammar as many others, the comma is completely irrelevant for the purposes of disambiguation. Commas could essentially be treated as whitespace and nothing would substantially change.

Now, I don't know whether commas allow for faster parsers in some way, but edn[1] seems to be doing just fine without them.

Once you get used to optional commas, it really becomes a nuisance having to type them, especially in basic data type lists. The only place where I find commas visually helpful is C-style argument lists (with type and value pairs), which JSON doesn't even use.

[1] https://github.com/edn-format/edn

Re: A modest proposal

#19

Yes, please! This applies to many other lists as well, not only restricted to JSON. Besides, imagine a world of Java, Javascript, C-like anything, where you would be DISALLOWED to have a semicolon after the last statement in a block. Crazy thought, right?

Some JavaScript style standards require no semicolons at the end of lines: https://standardjs.com/rules.html#semicolons

Re: A modest proposal

#20

Yes, please! This applies to many other lists as well, not only restricted to JSON. Besides, imagine a world of Java, Javascript, C-like anything, where you would be DISALLOWED to have a semicolon after the last statement in a block. Crazy thought, right?

Commas are unnecessary. There is zero benefit to having them. The code is actually easier to parse if you just remove them from the rules list entirely. No commas might look weird for a day or so, but you quickly get used to it. (I'm ignoring the comma operator, which is a special case and not relevant to the main point.)

They exist because of string concatenation. In some languages any consecutive strings are implicitly concatenated so that you can have a very long string split across many lines.
Post reply on HN