Hacker News new | ask | show | jobs
by progx 4371 days ago
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.

3 comments

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.