Live data from Hacker News

YAML and Configuration Files

utcc.utoronto.ca

11–20 of 96 posts

Re: YAML and Configuration Files

#11
My text editor, KeenWrite[0], integrates YAML using a GUI, which hides the underlying data format[1]. This makes the format irrelevant from the end user's perspective. Hardly anybody edits .odf files or .png files directly, yet configuration files are often updated in a plain text editor rather than a GUI. Structured data formats are amenable to autogenerating GUIs (see [2] and [3]).

[0]: https://github.com/DaveJarvis/keenwrite/blob/master/docs/scr...

[1]: https://youtu.be/u_dFd6UhdV8?t=160

[2]: https://www.jeremydorn.com/json-editor

[3]: http://mb21.github.io/JSONedit/

Re: YAML and Configuration Files

#13
There are a variety of generic DSLs for encoding configuration concisely with composability, functions, custom validation, etc. Some examples would be jsonnet, dhall, and cue.

If the configuration needs to be transformed into a more computer-friendly format like json or yaml for later loading by a binary, that's easy enough to do at build time in a modern-ish build system like bazel

Re: YAML and Configuration Files

#14
post #13

There are a variety of generic DSLs for encoding configuration concisely with composability, functions, custom validation, etc. Some examples would be jsonnet, dhall, and cue. If the configuration needs to be transformed into a more computer-friendly format like json or yaml for later loading by a binary, that's easy enough to do at build time in a modern-ish build system like bazel

If you're gonna be generating at build like that, you might as well be using a binary encoding like protos (this is for devs, btw)

Re: YAML and Configuration Files

#15
Currently, my main concern with YAML is that, by the spec, comments are not attached to a particular node (see https://yaml.org/spec/1.2/spec.html#id2767100). As a result, a lot of YAML parsers (like https://github.com/yaml/libyaml and https://github.com/chyh1990/yaml-rust) only filter out the comments during the parsing phase. This makes it less than ideal for a use-case where the configuration file is expected to be modified by both programs and humans.

TOML makes it more trivial to associate comments with a node. This is mainly because the language is simpler though, as the spec is not explicit about that (https://toml.io/en/v1.0.0#comment).

Re: YAML and Configuration Files

#17
post #10

Hm. I can see where the article is coming from. Some configuration files grow beyond classical configuration and end up being more like programming. With configuration being "Put the right connection / path strings into the program, enable some subsystems/feature toggles" and programming being along the lines of, e.g., arbitrary metric transformations in a metric collector, or programmable ACLs. With some systems, I…

yaml (and json) gives configuration files much-needed hierarchy and structure, which is unbounded (within reason), not limited syntactically or inherently like simpler configuration formats including toml.

yaml adds to that comments and a pleasant readable layout, even if it requires a little bit more from the editor to make it pretty.

With that, I don't think yaml has much competition.

Re: YAML and Configuration Files

#18
post #6

The solution for defining a more complicated config is to write your own config file format? I would think a custom format wouldn't necessarily be easier for others to read and write unless it came with a guide/readme, but then that's just one more thing to learn. Admittedly, I've never had to write a super complicated config file, but can anyone tell me why I shouldn't continue to use something like JSON for all of…

Compared to yaml or ini formats, JSON is arguably harder to read and definitely harder to write due to having to keep track of brackets, commas, and/or quotes. Ideally, a configuration file should be easy to read and write/modify by a user of the application. A lot of applications just stick with ini like formats because it meets both requirements.

Maybe it's because I've written C++ for years, but give me brackets over significant whitespace any day.

If anything, YAML is harder to read because the indentation is important, yet deliberately invisible.

Re: YAML and Configuration Files

#20
A while back it took myself, a data center engineer, and two engineers from the appliance vendor a solid 20 minutes to figure out the problems with a ~12 line yaml file that needed two or three lines added (network config file). Between syntax, indentation, etc it required a few tries. Plus there was a copy and paste in there via SSH.

I don't know what a better alternative is but yaml can be incredibly frustrating.

Post reply on HN