dub icon indicating copy to clipboard operation
dub copied to clipboard

Changing the format of `settings.json`

Open Geod24 opened this issue 5 years ago • 5 comments

I believe settings.json was a great addition to dub, something I've personally been wanting for a while. Allowing users to e.g. choose their default compiler without having to compile dub itself.

I'd like to extend it, for example by giving it the ability to use a specific Copyright / authors string by default, and by providing a default value for --cache. There are also a few bugs that need fixing (#1472 is trivial, for example).

However, currently, it suffers from one great downside which should make anyone wary of extending it: it is written in JSON.

JSON has proven to be a bad format for human-written configuration. Be it the lack of comments, noisy syntax, lack of typing... So much that a push was done to move to SDLang a few years ago. However JSON enjoys wide support among editors and tools, and is still familiar to people than SDLang, the later being yet another skill a newcomer to D has to pick up.

Hence, I would like to bring forth the idea of changing settings.json to use a different format. Out of all the markup languages out there, I my vote would go to YAML:

I think the comparison is fairly simple.

Would love some opinion from DUB / settings.json users.

Geod24 avatar Dec 23 '19 05:12 Geod24

I would like to add. That most importantly, YAML is a superset of JSON. All existing JSON files would still be readable by Dub if the format is changed to YAML. No need for multiple parser inside Dub. Perhaps only the file extension (.json) need to be deprecated.

jacob-carlborg avatar Dec 23 '19 08:12 jacob-carlborg

My vote goes for YAML as well :+1:

wilzbach avatar Dec 23 '19 13:12 wilzbach

Also my vote goes for YAML. It is well known in the industry. Although there should be no need to edit the settings file manually but dub should be capable to set the settings file values by a dedicated command.

andre2007 avatar Dec 23 '19 15:12 andre2007

I agree with @Geod24 high-level goals of extending setting.json's uses. I'm ok with using YAML (in addition to SDLang) as it's also growing in popularity among various other projects. However, unless we target this feature for 2.0, we need to keep backwards compatibility and continue supporting the current format of settings.json.

PetarKirov avatar Dec 25 '19 21:12 PetarKirov

After https://github.com/dlang/dub/pull/2310 we'll be able to do this fairly easily and in a backward-compatible manner.

Geod24 avatar Jul 28 '22 11:07 Geod24