dub: JSON, SDL, YAML, TOML, what color should we paint it ?

Steven Schveighoffer schveiguy at gmail.com
Wed Mar 1 14:21:12 UTC 2023


On 3/1/23 4:21 AM, Mathias LANG wrote:
> On Tuesday, 28 February 2023 at 15:35:58 UTC, Steven Schveighoffer wrote:
>> Json5. It's json but with comments and allows key names without quotes.
>>
>> https://json5.org/
> 
> I didn't knew it supported quoteless keys, that's pretty nice!
> If it's a superset of JSON, we could potentially do it in place too.

It also allows trailing commas.

> 
>> I have to say, I hate YAML. With a passion. The "backwards 
>> compatibility with JSON" is pretty must just bolted on. And having 
>> multiple ways to write configurations might be nice for people writing 
>> configs, it's not nice for people reading them. Also, significant 
>> whitespace = bad.
> 
> I think the significant whitespace boat has sailed. I don't like it 
> anymore than you do, but nowadays, editors align everything, and if they 
> don't, the linter will complain, or the reviewer will. As much as I 
> dislike it, I think significant whitespace just hasn't proved to be the 
> barrier it was envisioned to be, as demonstrated by Python and YAML.

It hasn't sailed for dub. Neither json nor sdl require significant white 
space.

>> I would be OK with TOML. But then we have 3 formats. Changing to a 
>> json-compatible format means we still only have to maintain 2 parsers.
> 
> Note that going with YAML allows us to deprecate the SDL parser. Going 
> with JSON5 includes writing a new parser, and a library to do what 
> Configy currently does, on top.

We will never be rid of SDL. Remember that dub has to not only parse the 
current config, but all tagged configs. Updating all old projects, and 
all previous tags of old projects, is not going to happen.

JSON5 requires *updating* the existing JSON parser. JSON is valid JSON5, 
so I think we would be OK just parsing `dub.json` and `dub.json5` 
equivalently. Even if not, the parser can have a flag whether to reject 
JSON5-specific features.

Also, what is configy? And why wouldn't yaml also require changes?

-Steve


More information about the Digitalmars-d mailing list