Hacker News new | ask | show | jobs
by tasogare 2100 days ago
JSON should be banned for configuration, if only for the fact it doesn’t support comments.
4 comments

Or trailing commas in lists/objects. That is 90% of what burns me every time I write JSON by hand.
Use HJSON, json with comments that doesn't kill you for a trailing comma.

All the benefits of JSON, no new syntax to learn, easy to fit in place in new or existing systems.

https://hjson.github.io/

Seems better than Json5.

All languages should make unnecessary characters optional like trailing semicolons and commas.

Yes. It's crazy that people somehow decided that XML is evil for configuration and JSON is good. YML is barely OK.

JSON is good for data exchange. Configs? That's crazy talk.

JSON is great, but not for config: It was never really meant to be written by humans.
I agree totally with you, but designing a language that's not "meant for humans" is an _incredibly_ stupid idea. Of course humans will try and write any protocol by hand. Who's gonna stop me?

If it looks like text, make it as easy as possible for humans to consume and write by hand. Period.

That's a small but very important reason why HTTP rules the world.

Really? How so? I thought the whole reason it won over XML for HTTP stuff was precisely because it could be easily written and read by humans.
By raw bulk most JSON is not written by humans, it is an interchange format. Yes of course a human is going to write JSON in snapshot tests. And it is for sure a feature that it is easily written by humans.

Notice I did not mention readability. JSON was always meant to be human-readable; and its popularity is a testament to the rapid turnaround on debugging that the readable aspect of JSON affords. This is, say, in contrast to BSON which is similar but not humanly readable, and unsurprisingly less popular despite its bandwidth advantages.

Config formats are, by raw bulk, generated by humans, and need to be readable (ideally reproducibly across implementations) by computers.

Of course it was meant to be written by humans - every programming language and text based data format was meant to be both written and read by humans. JSON is basically Javascript objects, and Javascript was definitely meant to be written by humans.