Ask HN: What do you like to see in a configution file format?
I'm working on a home automation system anyone can set up for themselves with one central configuration file[1]. What do you like to see in a configuration file format?
[1] based on this: https://github.com/robss2020/computerplayverysexymusic
16 comments
[ 5.5 ms ] story [ 42.5 ms ] thread2. I like the separation of data and the program and am not the biggest fan of using a full scripting language as a config file (sometimes popular js, php, and lua)
Bonus: Some way to specify variables for reusable values, not a deal breaker though.
Bonus 2: Not having to learn a radical new config file format.
Your comment about variables for usable values reminded me that it would be nice if the configuration file parser could reference other variables and sections of the configuration file to avoid repeating oneself in the same configuration file. for example, if the configuration files describing a fleet of virtual machines, it would be very handy to define small/medium/large system types with varying RAM, CPU counts, and disk layouts, then reference just the small, medium, or large type throughout the configuration file.
How do you suggest specifying a variable?
I'm glad most of the industry has got away from the binary blob for configuration file, but I don't see great advances that the new configuration file formats such as TOML or others I'm not aware of provide above a basic yaml or json file.
my personal preference is yaml followed by jason, and from what I understand the ability to convert between those two formats is because both have feature parody with the other. I might be wrong, but as long as a system can ingest either of those I find it my preference to use that over something else. maybe if I had a third place file format it would be ini, but it has a lot of restrictions on the type of data structures it can convey.
- documentation generator: aside from "human readable", have tooling support for documentation generation
- syntax/plausibility checking: tooling support for consistency checks
- UTF8 support
- variables: specify and populate placeholders
- modularisation: compose configurations out of reusable modules
- templates: something like #define in C
- concise: json, yaml and xml are too verbose imho. Maybe make use of special characters like ,!() etc for syntactical brevity
- unambiguous: indentation, capitalisation, the type of quotes etc shouldn't be syntactically relevant
- pluggability: APIs & libraries that allow using the language in my programmes
>concise: json, yaml and xml are too verbose imho I'm very surprised you include yaml in this. It doesn't seem to require me to use any syntax except a colon to separate the name from the value. (and optionally indentation to specify when something is logically a child value). How can that be too verbose? What would be a less verbose version?
You and others have all mentioned variables and placeholders to avoid repetition. How do you suggest specifying a variable?
> unambiguous: indentation, capitalisation, the type of quotes etc shouldn't be syntactically relevant
since you say types of quotes shouldn't be relevant how do you suggest I differentiate a generated image from a named one? I was thinking of making it:
module_image:"images/module.png"
to specify the path if the user created their own image, or allow them to generate one using:
module_image: generate
if they want the script to generate one using the module name, or they can follow generate with a prompt in quotes like this:
module_image=generate "keywords to use for image generation"
This would mean there are three formats module_image: would support depending on whether and where quotes are used. Without using quotes to differentiate, how would you suggest I let the user ask the script to generate the image for them rather than naming the location of the image?
Thank you for your feedback.
Reflecting on my remarks, I think I had large configurations in mind as they occur in kubernetes or terraform which can be tens of pages.
> How can that be too verbose?
I meant that yaml indentations eat up screen space, every attribute needs to go on a new line and is terminated by a colon, which seems redundant since the newline already delimits attributes. If you ever have written a large k8s deployment descriptor, you'll know that yaml is not the right language for describing complex configurations.
> How do you suggest specifying a variable?
Variables should probably be set outside the template, eg. reference environment variables or be set in INI or properties files... which makes them parameters rather than variables but potato potato. The template could then reference variables by a special notation eg. $myvar or following a naming convention eg. vMyVar.
> how do you suggest I differentiate a generated image from a named one?
I worded that poorly. I think parsers get too hang up on the details. '"`’«» etc could be all syntactic equals, unless a good use case justifies different meanings. Eg. bash has different meanings for different types of quotes. The parser probably could infer when a statement is a literal vs. a reference simply by checking if the reference exists.
> Thank you for your feedback.
If you put the specification for your configuration language on a git repo then interested parties could open issues and discuss specific topics.
By the way, although it is too much to open a repo for it, what do you think about this UML for how I structure the parts of the application?
https://imgur.com/a/FUTphwa
(I already have the parts working.) The user talks to the voice recognition engine which is a subprocess of the voice recognition server. In terms of what to do (actions to take) the voice recognition takes configuration files and dispatches scripts. To give feedback to the user the voice recognition server also communicates via a web interface. (i.e. the user could have this web interface open and see what actions the home automation server is taking, which scripts have been launched etc.)
Do you think this structure is all right for a configurable voice recognition automation server app?
Why would you want to build a new format over using an existing one?
Is it a good idea to still force a single file once the configuration reaches some sufficiently large size?
You mention "Is it a good idea to still force a single file once the configuration reaches some sufficiently large size?"
If it is not limited to a single configuration file what do you suggest is best practice for which one(s) should be loaded?
CUE naturally allows splitting config & schemas into multiple files.
You can split by purpose, whether CUE or traditional formats. Start with one until it makes sense to split for understandability