Live data from Hacker News

A reasonable configuration language

ruudvanasseldonk.com

21–30 of 111 posts

Re: A reasonable configuration language

#21
The problem isnt "configuration"

Yaml, JSON, xml, text files... all work great for configuration.

But the assumption is that your configuring a piece of software on an already existing system.

A config file as means of setting up a system, installing software, and establishing how its going to run is exceedingly stupid.

Write your app so it can run on bare metal, install with apt, yum or your tool(s) of choice for your org. Build it so it scales diagonally, and works against spot instances where you can (because sometimes more or less cores are cheaper). Dont even get me started on the nonsense of everyone and their ideas for "secrets management", it makes me miss LDAP.

Re: A reasonable configuration language

#22
I know the standard response is "why another one?" but honestly, his diagnosis of the existing options is pretty good. He even uses the best examples of thoughtfully designed config languages: cue, dhall and nix, and ... yeah I pretty much agree with his qualms about those languages.

What is a config language really? It's a language that doesn't allow side effects and evaluates to json.

Re: A reasonable configuration language

#23
post #4

jsonnet[1] and kapitan[2] are the tools I currently use. Their learning curve is not optimal (and I tried to contribute to smoothen it with a jsonnet course[3] and a 'get started wit kapitan' blog post[4]), but once used to it it's hard to do without, and their combination makes them even more useful (esp. if you deploy K8s). In Ruud's case, Jsonnet might have been worth looking at as Hashicorp tools can be configure…

The author mentions Jsonnet in the appendix[^1]:

> I never properly evaluated Jsonnet, but probably I should. Superficially it looks like one of the more mature formats, and in many ways it looks similar to RCL. Its has a page comparing itself against other configuration languages.

[^1]: https://ruudvanasseldonk.com/2024/a-reasonable-configuration...

Re: A reasonable configuration language

#24

The problem isnt "configuration" Yaml, JSON, xml, text files... all work great for configuration. But the assumption is that your configuring a piece of software on an already existing system. A config file as means of setting up a system, installing software, and establishing how its going to run is exceedingly stupid. Write your app so it can run on bare metal, install with apt, yum or your tool(s) of choice for yo…

Are you suggesting that all configuration should be dynamic and multi-tenant (for the lack of a better word), not happen at startup?

Re: A reasonable configuration language

#25
post #19
post #18

Earlier quoted context omitted.

Don't repeat yourself / single-point-of-truth. Config files can be full of repetition, from values, to sections/objects. Defining a value or object once, dramatically reduces search+replace errors for example.

Is that mutually exclusive with using your normal programming language as a config language?

What do you do when your normal programming language stops being your normal programming language (you add a language, switch languages), but you want to preserve details of the configuration? Translate it all into your new language(s)? How do you keep these things synced up? You extract the details into a configuration language/serialization format and then deserialize in every language you work with.

Embedding your configuration in your application language only works well as long as you have one application language. (Or perhaps you use Lua or TCL which are both almost trivially embedded into every other language.)

Re: A reasonable configuration language

#26
post #23
post #4

jsonnet[1] and kapitan[2] are the tools I currently use. Their learning curve is not optimal (and I tried to contribute to smoothen it with a jsonnet course[3] and a 'get started wit kapitan' blog post[4]), but once used to it it's hard to do without, and their combination makes them even more useful (esp. if you deploy K8s). In Ruud's case, Jsonnet might have been worth looking at as Hashicorp tools can be configure…

The author mentions Jsonnet in the appendix[^1]: > I never properly evaluated Jsonnet, but probably I should. Superficially it looks like one of the more mature formats, and in many ways it looks similar to RCL. Its has a page comparing itself against other configuration languages. [^1]: https://ruudvanasseldonk.com/2024/a-reasonable-configuration...

I should have made it clearer, but I wrote my comment in reaction to his mention that he "never properly evaluated Jsonnet".

Re: A reasonable configuration language

#27

The configuration rabbit hole, for practically any system that becomes widely applied or through large amounts of feature iterations. With provisioning systems you rapidly walk the ladder because they are basically starting about five steps down on this already: You start with an INI/yaml/json Then you might have several overlaid INIs Eventually: https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/refer... Go ahea…

Hum, most systems do not go down that hole at all. Most software stop at most at hierarchical parameters.

For the ones that do go down the hole, you are almost always better on separating them into components, to minimize the ones that need complex configuration, and accelerating the journey of those small pieces. (But yeah, it would be nice to settle on a good workflow description language that isn't a makefile.)

Now, it seems that everybody that is pushing those high-complexity languages wants an infrastructure description language, and just keeps calling it by "configuration language". Since those two problems are completely different, insisting on using the wrong name is quite harmful to the goal.

Re: A reasonable configuration language

#28
> I was struggling with that day was to define six cloud storage buckets in Terraform...The kind of thing you’d do with a two-line nested loop in any general-purpose language

I understand this is just an example, but FYI the modern solution is to use CDKTF rather than HCL for Terraform.

That allows you to choose your favorite general purpose lang: Python, TypeScript, Go, Java, C#.

Re: A reasonable configuration language

#29
I quite like what has been come up with here. In particular, I understand exactly how HCL would drive someone down this path, as it is infuriating to try to get that language to compute what you want computed.

I think at the end of the day, k8s YAML is focused on the datatype, i.e., what would be the result of your `rcl evaluate`. I do think this would be a much saner path than what Helm provides, though, and Helm's textual templating, as opposed to understanding values and building the actual datastructures, and then converting that to a format like JSON or YAML … is the wrong path. (I.e., I can see RCL being a possible replacement for Helm.)

> The language is a superset of json.

I'm going to introduce what I think is pretty much a universal law: languages claiming to be supersets of other languages are not supersets.

In the case of JSON, there's basically one counter-example that breaks all alleged supersets:

  "\ud83d\udca9"
And if we try it:

  » printf '"\\ud83d\\udca9"' | cargo r -- evaluate
      Finished dev [unoptimized + debuginfo] target(s) in 0.01s
       Running `target/debug/rcl evaluate`
  stdin:1:2
    ╷
  1 │ "\ud83d\udca9"
    ╵  ^~~~~~
  Error: Invalid escape sequence: not a Unicode scalar value.

  Help: For code points beyond U+FFFF, use '\u{...}' instead of a surrogate pair.
Now! This to me is not a bug in RCL: this particular facet of JSON is utter crazy town, and I would strongly encourage you to not adopt it. (Since down this road lies madness, like unpaired surrogates. JSON's grammar & standard is sloppy here, and JSON/JS's syntax of using the UTF-16 encoding, and not just the scalar value … it's the part of JavaScript that is just what JS is, but is the part that we shouldn't be copying.)

It is much saner to just have a flag/way to indicate "my input is JSON" and then to just parse it via an actual JSON parser. Then let RCL evolve on its own merits. If there's a lot of happy overlap, and most JSON documents are blissfully polyglots with RCL, that's fine too / a happy little accident. (But the option is important if you want to apply it somewhere programmatically, where the inputs are JSON.)

YAML breaks the same way, too: it too is a "superset" of JSON that isn't.

Re: A reasonable configuration language

#30
post #9
post #6

Earlier quoted context omitted.

The article did not advocate for a TC config language. I think Ruud would probably have been happy with a total primitive recursive language.

To me the distinction is not important. It is possible to write programs that take too long to execute in non-Turing complete languages, and when a program hangs, you just terminate it. I think what people really want is for their configuration to remain simple, but not being Turing complete does not guarantee that. For RCL I added a limit on the number of evaluation steps, because without it some programs trap the f…

We agree. You don’t want universal computation in your configuration. Your “gas” approach is the right one and very weak computationally. I further posit that you don’t even want to offer gas fuelled TC and everyone would be happy with a provably total primitive recursive language fuelled by gas. Why? Accidents happen. I’d rather have my configuration tool tell me statically that some construct isn’t provably terminating than wait to find out later when someone imports my config snippet library and uses it in an unexpected way.
Post reply on HN