Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have had great experience using JSONNET (https://jsonnet.org/) as a configuration language. It supports variables, inheritance, operators, functions, substitutions, types, with just the right amount of power, expressiveness, and simplicity.

In my opinion, JSON is best used as a wire-protocol. It is awkward as a configuration language.

YAML works for short configs, but becomes unmaintainable for longer configs. I think the primary problem is that the indentation is significant. I also think the language spec is far too complex.

INI format works for short configs, but also becomes unmaintainable for longer configs. Ironically I think this is because INI is too primitive, the opposite problem of YAML, but has the same effect.

I am not familiar with TOML or DHALL, mostly because I stopped looking after I implemented the JSONNET system and liked it so much.

Addendum: I have used text-formatted protobufs in limited situations with good results. But I don't think that protobufs is a good general purpose configuration language.

Addendum2: The amazing thing about simplicity of the INI file format is that I was able to write a "single line" sed program to parse it in a bash script. The following finds the value of the $key in the $section in the $config_file INI file (definitely works on GNU sed, I think it works on MacOS sed too, not 100% sure though):

    sed -n -E -e \
        ":label_s;
        /^\[$section\]/ {                                                       
            n;                                                                  
            :label_k;                                                           
            /^ *$key *=/ {                                                      
                s/[^=]*= *//; p; q;                                             
            };                                                                  
            /^\[.*\]/ b label_s;                                                
            n;
            b label_k;
        }" \
        "$config_file"


> I think the primary problem is that the indentation is significant.

An editor problem, perhaps? We don't maintain office documents using vim; why edit structured configuration files using a plain text editor, if doing so is arduous?

My text editor[0] abstracts the underlying hierarchical data format behind a tree-based widget[1]. Whether YAML, JSONNET, NestedText, CSON, XML, or TOML backs the widget becomes an implementation detail.

[0]: https://github.com/DaveJarvis/keenwrite

[1]: https://dave.autonoma.ca/blog/2019/07/06/typesetting-markdow...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: