| ▲ | conartist6 6 hours ago | ||||||||||||||||||||||
A lot of people dislike that decision not to include comments in JSON, but I think while shocking it was and is totally correct. In a programming language it's usually free to have comments because the comment is erased before the program runs; we usually render comments in grey text because they can't change the meaning of the program. In a data language you have no such luxury. In a data language there's no comment erasure happening between the producer and the consumer, so comments are just dangerous as they would without doubt evolve into a system of annotations -- an additional layer of communication which would then not be standardized at all and which then would grow into a wild west of nonstandard features and compatibility workarounds. | |||||||||||||||||||||||
| ▲ | phlakaton 4 hours ago | parent | next [-] | ||||||||||||||||||||||
I don't dislike the decision at all, FWIW! For data interchange it's totally reasonable. But it does make JSON ill-suited for a bunch of applications that JSON has been forcefully and unfortunately applied to. | |||||||||||||||||||||||
| ▲ | zahlman 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
> In a programming language it's usually free to have comments because the comment is erased before the program runs That's inherent to the language specification, but it isn't inherent to the document. You have to have a system with rules that require that erasure. Nothing prevents one from mandating a system that strips those comments out of JSON. You could even "compile" JSON to, I don't know, BSON or msgpack or something. Just as nothing prevents one from creating tooling to, say, extract type annotations from comments in a dynamically typed language. | |||||||||||||||||||||||
| ▲ | heresie-dabord 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
> while shocking it was and is totally correct Agreed —— consider how comments have been abused in HTML, XML, and RSS. Any solution or technology that can be abused will be abused if there are no constraints. | |||||||||||||||||||||||
| ▲ | blackcatsec 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
Could you imagine hitting a rest api and like 25% of the bytes are comments? lol | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | jancsika 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
> so comments are just dangerous as they would without doubt evolve into a system of annotations -- an additional layer of communication which would then not be standardized at all and which then would grow into a wild west of nonstandard features and compatibility workarounds IIRC Douglas Crockford explicitly stated that he saw people initially using comments for a purpose like ad hoc preprocessor directives. | |||||||||||||||||||||||
| ▲ | quotemstr 4 hours ago | parent | prev [-] | ||||||||||||||||||||||
No, it was obviously and flagrantly incorrect, as evidenced by the success of interchange formats that do allow for comments, including many real world systems that pragmatically allow comments even when JSON says they shouldn't. This is Stockholm Syndrome. But what can we expect from a spec that somehow deems comments bad but can't define what a number is? | |||||||||||||||||||||||