Manage Configurations: File Format
Indeed, there are a bunch of formats available. Just list a few popular choices here:
- JSON. Everyone who reads this post right now should have know it :)
- INI. Do you know there is an operating system, called Windows?
- YAML. Examples are Kubernetes, Jekyll, and CircleCI.
- TOML. Examples are PEP 621, which introduces
pyproject.toml
to Python, and Cargo, which usesCargo.toml
to configure every Rust crate. - XML. Examples are Apache Hadoop and Apache Ant.
(Thanks to ChatGPT for providing some of the examples.)
I'd like to put the related formats into four categories, roughly based on the expressivity:
- Lightweight configuration formats. Examples are JSON, INI, TOML, XML. There are basically human-readable serialization of dictionaries/lists.
- Medium weight configuration formats. Examples are YAML, OmegaConf. These are more complex (in the sense that templating is possible to some extent) but not fully-fledged.
- Heavyweight configuration formats. Examples are Nickel, Dhall, Jsonnet, Pkl and RCL. They introduce variables and function, becoming serious Domain-Specific Languages. Some of them are even Turing-complete.
- General programming languages. Examples are Python (JupyterHub), Lua (WezTerm , neovim), VimL (Vim), Emacs Lisp (Emacs), and even Haskell (xmonad). What I find out is that these projects usually need to define functions/callbacks. I won't discuss them in this post.
Here is a comment from HackerNews, which has a similar classification:
- Level 1 is just values in a file. The Linux kernel uses that.
- Level 2 is a list of values, e.g. ini files.
- Level 3 allows nesting. JSON, XML, and YAML are here.
- Level 4 allows computation but limited. Dhall and Starlark are here.
- Level 5 is a Turing-complete language. Python, Javascript, etc.