Remix.run Logo
epolanski 2 days 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.

Terr_ 2 days ago | parent | next [-]

> 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.

eternityforest 2 days ago | parent | prev [-]

Programmatically manipulating it and validating it gets harder though.

themafia 2 days ago | parent | next [-]

Unless it's a lisp.

maxbond 2 days ago | parent [-]

Specifically 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 2 days ago | parent | prev [-]

How so?