News for hackers. Stuff that matters.
Re:In Defense of COS, or Why I Love JSON and Hate XML by randomfool on Sunday December 02, 2012 @03:06PM (#4862316)
Dings XML for crappy commenting syntax then gives JSON a pass for not supporting comments at all.

I love JSON, but it does have it's issues.

Re:In Defense of COS, or Why I Love JSON and Hate XML by wvenable on Sunday December 02, 2012 @03:59PM (#4862480)
JSON not having comments is a benefit when used for it's primary purpose: information exchange. JSON is not a great format for configuration files or static documents even though it's increasingly used for it.
Re:In Defense of COS, or Why I Love JSON and Hate XML by ishbits on Sunday December 02, 2012 @04:18PM (#4862544)
YAML is better suited for configuration files.
Re:In Defense of COS, or Why I Love JSON and Hate XML by jpravetz on Sunday December 02, 2012 @05:17PM (#4862775)
I wish there existed a popular config format that was somewhere between YAML and JSON. In my current nodejs project I sometimes use js files for config because js supports comments and is more lenient on syntax then JSON. I prefer using { } to group objects, rather then YAML indenting, but otherwise am okay with YAML and only don't use it because the parser is not part of Javascript or nodejs.
Re:In Defense of COS, or Why I Love JSON and Hate XML by joe_the_user on Sunday December 02, 2012 @05:05PM (#4862720)
Yaml is not good for configuration files because it is not easily human-editable. It seems "easy" but meaningful whitespace is a cluster-fck.

Edit: I have been looking for reasonable configuration file formats for a while. Json actually has pretty bad human-readability at any scale because of its quoted key-values. Yaml is easily readable but when a user tries to change anything, things go to hell. The humble ini-file has won so far. It's limited and not fully standardized but it is human readable and human writable. I'd love see something better but human readability/writable is going trump all sorts of cleverness.

Edit2: From http://en.wikipedia.org/wiki/YAML "The specific number of spaces in the indentation is unimportant as long as parallel elements have the same left justification and the hierarchically nested elements are indented further."

Yeah, a user of your software is going to be able to understand when they mess up on that rule, riiiight. Screw Yaml.

Re:In Defense of COS, or Why I Love JSON and Hate XML by chipsy on Sunday December 02, 2012 @06:14PM (#4863003)
I rolled my own format specifically for configuration. No significant whitespace, delimiters may dangle, and the parser implementation can be configured to accept very high ambiguity(including, if desired, mixtures of sequence and key-value data).

https://github.com/triplefox/triad/blob/master/dev/com/ludam...

A "real-world" example https://github.com/triplefox/triad/blob/master/examples/Asse...

Re:In Defense of COS, or Why I Love JSON and Hate XML by jscn on Sunday December 02, 2012 @07:23PM (#4863265)

  It seems "easy" but meaningful whitespace is a cluster-fck.
Tell that to everyone using Python. If your editor can't handle meaningful whitespace transparently, it sounds like you need a better editor.
Re:In Defense of COS, or Why I Love JSON and Hate XML by joe_the_user on Monday December 03, 2012 @03:18PM (#4867554)
you need a better editor

I think you misunderstand the concept of "configuration file". These are not intended for programmers but for users of the program you write.

White complaints about Pythons' meaningful white are still common, programmers can get over that by, indeed, getting a better editor or otherwise wrapping their head around the situation.

But end-users can't be expected to have this kind of sophistication. Explaining to someone while things they can't see have made their program usable is no fun.

Re:In Defense of COS, or Why I Love JSON and Hate XML by sigzero on Sunday December 02, 2012 @08:46PM (#4863503)
Python is a programming language. Worlds of difference there.
Re:In Defense of COS, or Why I Love JSON and Hate XML by masklinn on Sunday December 02, 2012 @03:48PM (#4862444)
On the other hand, comments were explicitly excluded from JSON by Crockford (with the thinking — probably correct — that they'd be abused to embed such things as parsing directives or other out-of-band content)
Re:In Defense of COS, or Why I Love JSON and Hate XML by TazeTSchnitzel on Sunday December 02, 2012 @05:01PM (#4862705)
I believe he was correct at the time, he removed them once people started using them for parsing directives. (JSON hasn't always been frozen)
Re:In Defense of COS, or Why I Love JSON and Hate XML by angersock on Sunday December 02, 2012 @07:46PM (#4863349)
Having seen/used the rudimentary commenting mechanism in Wavefront .OBJ files (a 3D interchange format) to stuff in more modern information (tangents, additional UV channels, etc. etc.), I can say that comments can help a format live on well past its expiry date.

That said, I will not pretend for a second that this is a good idea. Crockford did the right thing.

Re:In Defense of COS, or Why I Love JSON and Hate XML by pippy on Sunday December 02, 2012 @05:19PM (#4862785)
Explicit is better than implicit. If you have to explain something you've probably written the JSON wrong.

You can always do this:

    {
        'people' : 10,
        'desc': 'People who will attend'
    }
Re:In Defense of COS, or Why I Love JSON and Hate XML by mcantelon on Sunday December 02, 2012 @06:02PM (#4862957)
>Explicit is better than implicit.

Which is why not intermingling comments with data makes sense.

>If you have to explain something you've probably written the JSON wrong.

You could say the same about code: "if you need to comment then your code isn't clear enough". In reality sometimes commenting code or data is helpful.

Re:In Defense of COS, or Why I Love JSON and Hate XML by rdtsc on Sunday December 02, 2012 @08:20PM (#4863433)
JSON not having comments is a deliberate design decision (a feature if you want). The reason is if it supported comments, they would have ended up being used to for meta languages and parse directives that would have created JSON documents that could not be parsed or processed by all JSON parsers -- it would have fragmented the JSON ecosystem quite a bit. So it might seem like an accidental bug or omission but it is not it is on purpose and I agree with it.
Re:In Defense of COS, or Why I Love JSON and Hate XML by mikeash on Sunday December 02, 2012 @05:13PM (#4862755)
I don't know that it applies here, but sometimes it is better to not have a feature at all than to have it badly.