Configuration languages

XML has been in use for a long time, and most programmers are likely familiar with it. It also has comprehensive tooling. Other than that it's garbage. It has an extremely verbose syntax, and the difference between attributes and children is very arbitrary.

JSON fixes some of these problems by having one type of nested data: properties. JSON also has a very simple syntax, with most delineations only requiring a single character. There are, however, still three main issues with JSON. The specification does not allow for comments, which is an absolute deal breaker in some environments. Strings are only single line, which causes long form text to be unfriendly to readers. And deeply nested addresses can be very difficult to find. If I'm looking for foo.bar.baz, I might have to scan through lines one by one, keeping very careful track of my current location and the occurrence of brackets in order to find my desired target. The structure also makes it difficult to use normal text search to find the desired location in one go, though you can use repeated text searches if you work patiently and deliberately.

YAML fixes two of the three issues I have with JSON. It has comments, multiline strings, but its addresses are still based on nesting. It also introduces new problems similar to my problem with attributes in XML. There are too many features in YAML that make it unnecessarily complex. A particularly pervasive example is the ability to use sequences (arrays) as keys. For most projects, finding a use for all of these features would be a chore, and given the fact that YAML is a data language which needs to be interpreted to have any effect on software, these added features actually get in the way of using YAML for most projects.

TOML is my favorite configuration language I've found so far. It fixes all of my issues with JSON. In addition to comments and multiline strings, the tables in TOML (objects in JSON) can specify their address fully, and the TOML parser will simply merge the objects later if converting to JSON. This means that I can specify [foo.bar.baz] directly in code to be searched for later. TOML also has an extremely minimal syntax—one which could be learned in under ten minutes by most developers.

https://toml.io/en/

I will likely continue to use JSON regularly in my career, if for no other reason than it being the native data language for the web. But I would prefer another option in almost every other context. If I needed a data store I would prefer to use sqlite, as I know it will be fast, and come with excellent tooling for that purpose. And if I needed a human readable config file, I would certainly prefer to use TOML, or even just a multiline text file if my needs were simple enough.

#software