Hacker News new | ask | show | jobs
by barosl 4221 days ago
Regarding the configuration formats, I would recommend TOML.

In fact, I hated it because it seemed to be just "another standard" that unnecessarily adds dependency.

But after using Rust, whose package manager forces me to write the package configuration in TOML, I found the format is more like "JSON designed for configuration file." As you said, JSON is full of ':', '{' and '}'. And it is natural because it started from data interchange format, not for handwriting. TOML solves this problem very well IMHO.

Also, unlike XML that requires an external structure to validate the types of the values, TOML values have types, just like JSON.

5 comments

There's also http://p3rl.org/JSONY which is explicitly "JSON re-imagined for configuration files" by myself and ingy (the creator of YAML).

The key win for us is that all JSON is valid JSONY, so you can use the human friendly syntax for hand editing but still just dump out a JSON object into the file if you're generating the entire thing from code.

Can you give some examples of TOML-based Rust package configurations that you think are good? My experience using TOML for config files has been very different.

IMO, using YAML for the config format is still the best option for most use-cases at this point. (Easy to support both json and YAML.) But I do think that it would be great to have a YAML successor that standardizes some of the cool things people are doing with custom YAML parses, and also removes outdated and unnecessarily complex parts of the original standard.

Is there some reason for the commas in lists? I'm starting to like s-exprs more and more for configs and am starting to think it might be because of a lack of love for commas.
It just seems that TOML (and similar formats) would be more of an interface rather than the configuration itself.