Currently, Dub uses two formats: JSON and SDL.
JSON was there from the beginning, I assume due to Dub's npm inspiration.
In fact, we still very much depend on JSON internally: until recently, JSON object were passed around in quite a few places. When we download a package, regardless of the format the package recipe is in, we store it as dub.json
.
But JSON is a terrible format to write configurations in, given how verbose it is, and it lacking support for comments.
So around 2014, we added support for SDL (no, not this one, or this one, but this one, and it took me 10 minutes to find the link because Wikipedia doesn't even know about it).
At some point last year, I did some heavy refactoring on dub along with quite a few improvements. In the process of doing so, I took advantage of the fact that YAML is a subset of JSON to add a YAML parser, on which I have built a library to do automatic configuration parsing, because let's be honest, it's 2023 and we're using the language with the best compile-time reflection capabilities, so we really don't want to manually parse a standard file format to fill a struct.
This parser is used to parse all JSON files:
dub.json
(but notdub.sdl
);dub.selections.json
;dub.settings.json
;
Now, I think that having dub.settings.json
being written in JSON doesn't make sense, and I would like to change this. In fact, I have been wanting this for more than 3 years, and the people that took part in the discussion broadly agreed.
Here are the options that have been floated around:
- Use SDL everywhere;
- Add support for YAML;
- Add support for another format (E.g. TOML);
I would like to go with YAML, not because it is the greatest format on earth, but because SDLang is not well known (it means newcomer have to learn yet another format, and while not a big deal, it adds friction), while YAML is everywhere. In the thread were SDL was discussed, people even thought we invented it!
In practice, this would mean adding support for the file format with a YAML extension, giving it priority over the old format, then after a number of releases (most likely 10, probably more for dub.json
), deprecating the JSON / SDL equivalent.
Obviously such a change would not happen overnight, and would need broad support from the community. Opinions ?