6 ms·
Why not just use JSON? Infact, why not just use npm's package.json?
by yazaddaruvala 12y ago
Why not just use JSON?
Infact, why not just use npm's package.json?
- Svip 12y agoI 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.
- vlisivka 12y agoValid JSON: { comment: "The comment." }
- progx 12y agoExample 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.
- mercurial 12y agoIt's sad to see that the guidelines about downvoting are clearly not respected.
- simias 12y agoI 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?
- wtetzner 12y agoComments 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?
- riquito 12y agoYou'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).
- bryanlarsen 12y agoYAML is a serialization format, not a configuration format.
- stormbrew 12y agoIt'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.
- pandatigox 12y agoI think that's a good point. Why use .toml when we have better alternatives already? (I admit I have a bias against toml, but still...)
- the_mitsuhiko 12y agoWhich ones would that be?
- mateuszf 12y agoHow about s-expressions :) ?
- phloxicon 12y agoYAML is quite mature, clean, is a superset of JSON so people could use JSON if they wanted, and it's used for config files for pub, Dart's package manager. TOML doesn't seem mature enough.
- bjz_ 12y agoTOML is extremely simple. YAML on the other hand is incredibly hard to implement. JSON has no comments and is not really that nice for humans.
- nimish 12y agotoml is unstable and has no real spec + YAML has a well defined spec and is widely used?
- cmrx64 12y agoBecause comments.
- deleted 12y ago[deleted]
- cmrx64 12y agoThere isn't a lot of attachment to the exact manifest format used, but using json is clearly a step backwards!
- baq 12y agojson is only marginally easier to edit by hand than xml. also, comments.
- jdeseno 12y agoThe read-manifest command seems to output a JSON of your Cargo.toml if you have tools you'd like to use that require it: cargo read-manifest --manifest-path .
- illumen 12y agoYeah, why use some format that no one knows, and is harder to parse by other tools?
- nirvdrum 12y agoNot only that, but TOML is still considered unstable by its author. Granted, it hasn't been updated in several months. But that seems like a shaky foundation to be building on top of. From: https://github.com/toml-lang/toml https://github.com/toml-lang/toml "Latest tagged version: v0.2.0. Be warned, this spec is still changing a lot. Until it's marked as 1.0, you should assume that it is unstable and act accordingly."
- steveklabnik 12y agoWhile this is true, NOTHING in Rust-land is stable yet, so it's not as big a deal.
- nirvdrum 12y agoThat's not really carte blanche to build everything on unstable technology. The point is things are supposed to be converging on stabilization. And a lot of what's unstable now is under the direct control of Rust. What TOML does or doesn't do is now a matter that needs to be worked out with Tom. It's not confidence-inspiring in the least. If the plan is to jettison TOML, then it's simply just an odd choice to use for a first cut. And from a purely perception manner, seemingly reaffirms concerns some have had about the bundler team building cargo (right or wrong).
- steveklabnik 12y agoThe plan isn't to jettison TOML, but even though it's 'unstable,' it hasn't changed in a very long time. And, given, uh, Tom, I doubt it will very much. He has better things to do these days. I can see an argument for INI files, but TOML is basically INI with some extensions. And YAML (which has no Rust parser, and nobody who wnats to write one) and JSON (which does have one in the standard library) are very poor configuration formats. Which one would you have preferred? It seems like a reasonable choice to me. > And from a purely perception manner, seemingly reaffirms concerns some have had about the bundler team building cargo (right or wrong). You could just spell out the personnel issues rather than being all FUDdy about it. (I'm friends with Yehuda, but also was room-mates with the current maintainer of Bundler (until very recently). Bundler isn't perfect, but lots of that had to do with people assuming a pre-1.0 project is stable, and upstream bullshit with RubyGems.)
- zimbatm 12y agoJSON is annoying with the commas. One forgotten comma or comma too much and the whole file doesn't parse.