3 ms·
Imho the best configuration file is code written in the language itself. Configuring TypeScript applications with the `defineConfig` pattern that takes asynchr
by epolanski 1y ago
Imho the best configuration file is code written in the language itself.
Configuring TypeScript applications with the `defineConfig` pattern that takes asynchronous callbacks allowing you to code over settings is very useful. And it's fully typed and programmable.
It's particularly useful because it also allows you to trivially use one single configuration file where you only set what's different between environments with some env === "local" then use this db dependency or turn on/off sentry, etc.
Zig is another language that shows that configuration and building should just be code in the language itself.
- eternityforest 1y agoProgrammatically manipulating it and validating it gets harder though.
- themafia 1y agoUnless it's a lisp.
- maxbond 1y agoSpecifically what you want is to provably halt and to be free of side effects. There's some configuration languages with these properties for providing expressions in JSON configs (I'm blanking on their names for the moment) which generally don't advertise themselves as Lisp dialects but boil down to a Lisp AST written in JSON. Another example is Starlark, which provides Python-like syntax. Note that this implies a Turing incomplete language. Which makes sense - our goal is to make dangerous programs unrepresentable, so naturally we can't implement every algorithm in our restricted language.
- epolanski 1y agoHow so?
- Terr_ 1y ago> Imho the best configuration file is code written in the language itself. This depends on the trust-model for who is doing the configuration, especially if you're trying to host for multiple tenants/customers. Truly sandboxing arbitrary code is much harder than reading XML/JSON/etc.