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

I may not be a majority here, but I see JSON as a data transportation format, while I see TOML or YAML as configuration formats.

You cannot write comments in JSON, for instance.



You're not alone. YAML or similars are the right formats for these things, not JSON. Less clutter, comments separated from data, easier to read (by humans).


Example from the website in json

    {
      'package': {
         'name': 'hello-world',
         'version': '0.1.0',
         'authors': [ 'wycats@example.com' ]
      },
      'bin': {
        'name': 'hello-world',
        'comment': 'the name of the executable to generate'
      }
    }
So where is the problem ?

And you have the advantage, that other tools can use the complete file including the comment. In TOML you need an extra parser to grab the comment.


I don't really care what format the cargo files use (that's just an inconsequential bikeshed as far as I'm concerned) but in your example "comment" is really not a comment. I would expect to be able to put free-form comments anywhere I want and have them thrown away by the parser.

Your solution works fine for docstrings, but comments and docstrings are not the same thing (although many languages that don't support docstrings in the syntax hack them together using comments, admittedly).

But beyond that, what's the argument for switching to json? Is there some kind of intercompatibility with npm/Node.js to be gained?


Comments aren't just used to put notes in the file. They're also used to comment out code.

Also, having to quote everything makes writing JSON by hand a pain. Why would you want to use it over a nicer format?


It's sad to see that the guidelines about downvoting are clearly not respected.


YAML is a serialization format, not a configuration format.


It's really a configuration format that mistook itself for a serialization format.

What I wouldn't do for a cut-down YAML standard with most of the serialization crap cut out.




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

Search: