News for hackers. Stuff that matters.
Re:What Is Wrong with TOML? by baq on Wednesday September 13, 2023 @06:33AM (#37494879)
Eagerly waiting for a Yet Another Human Readable and Writable Graph (Which Is Mostly a Tree But Not Always) Serialization Language With Built In Schemas and Pure Functions, Maybe made with <3 for humans.

Actually, that, but without sarcasm. YAML is crap. TOML is crap. JSON is crap. INIs are actually fine for flat lists but major crap otherwise. Anything Turing-complete is completely inadequate crap for the purpose.

Re:What Is Wrong with TOML? by ducktective on Wednesday September 13, 2023 @06:39AM (#37494918)
Nickel[1] maybe? Though I'm not sure about "for humans" part :)

[1]: https://github.com/tweag/nickel

Re:What Is Wrong with TOML? by RedNifre on Wednesday September 13, 2023 @06:33AM (#37494884)
Re:What Is Wrong with TOML? by masklinn on Wednesday September 13, 2023 @06:55AM (#37495034)
I like edn but I’m not convinced it’s great for configuration.

First off, it shares the desire for extensibility with yaml (in the form of tags), which is a giant trap. And then it’s quite syntactically noisy.

Re:What Is Wrong with TOML? by dkersten on Wednesday September 13, 2023 @07:10AM (#37495149)
I love EDN (especially the integrant extensions) for configuration of the stack — that is, dependency injection and so on, the developer-focused configuration.

For user-facing configuration I still favour TOML. I think it’s a bit application dependent, sone applications (eg nginx) have complex configuration needs and for that it makes sense to use something more sophisticated, but for many user-facing config settings, a simpler-TOML would be a great fit. Basically just some basic key-value pairs that can be collected into groups. As the article states, the parsing types should perhaps be enforced by the parser not the written config.

Re:What Is Wrong with TOML? by jmkr on Wednesday September 13, 2023 @10:30AM (#37497251)
Why do you love edn? Specifically I also like edn, but I always felt like my use of it was glorified json.

I did like integrant, at least I felt like I understood it, unlike component.

There were two things about edn that made it seem better than json to me, tagged elements (and readers), and symbols. I don't remember exactly my use case but I used symbols in edn to something like namespace-resolution for multimethods. It was something like including a file in a classpath or loading a file, dev vs prod kind of config.

Re:What Is Wrong with TOML? by dkersten on Wednesday September 13, 2023 @04:08PM (#37501092)
I suppose mostly superficial reasons such as liking the keyword syntax better that using string keys in json, but also the richer set of data types (like sets), although that mostly doesn’t matter in practice, but it is very nice when using Clojure since the Clojure types just work. As an interchange or storage format it’s also nice to be able to store Clojure types and get them back the way they were out in, which if using json you would lose some information.

Mainly it’s just personal taste and no deep reasons.

Re:What Is Wrong with TOML? by dkersten on Wednesday September 13, 2023 @06:58AM (#37495070)
I especially love the Integrant[1] version which uses the E from EDN (extensible) to add references:

    {:adapter/jetty {:port 8080,
                     :handler #ig/ref :handler/greet}
     :handler/greet {:name "Alice"}}
[1] https://github.com/weavejester/integrant
Re:What Is Wrong with TOML? by eternityforest on Thursday September 14, 2023 @12:44AM (#37505076)
Too many features that can't be represented in standard programming language constructs..

JSON-alikes are opinionated. They don't let you do stuff that requires a plugin for the parser to work with

Re:What Is Wrong with TOML? by conradludgate on Wednesday September 13, 2023 @06:48AM (#37494986)
Maybe kdl[0]? It's a document language somewhere in between xml and yaml without all the crap of either IMO

[0]: https://kdl.dev/

Re:What Is Wrong with TOML? by alpaca128 on Wednesday September 13, 2023 @07:16AM (#37495203)
I use KDL in a (not too complicated, yet) config file of a project and I like it a lot. Tree structure with attributes like XML but with less syntax than JSON. Nothing redundant but has basics like comments.
Re:What Is Wrong with TOML? by jmaker on Wednesday September 13, 2023 @06:50AM (#37495003)
Dhall is superb, https://dhall-lang.org
Re:What Is Wrong with TOML? by 37469920away on Wednesday September 13, 2023 @09:39AM (#37496585)
Thanks for that, it is interesting.

Is this actually something I want to see in a configuration script? Why not just use a scripting langauge and be done with it? I wonder if the safety features can't be replicated with rigorous testing of say python as config scripts instead of learning yet another programming language?

https://prelude.dhall-lang.org/Text/concatSep.dhall

I think this is the key fulcrum for me: "config is code", sure, but not the same kind of "code".

It -is- compelling to argue for statistically deterministic config code but my practical objection here is 'can we arrive at same safety using testing with a known language?'

Writing this has made consider whether configuration should be conceptually looked at as a database instead of "code". How many people even know how e.g. postgres stores its tables and why would modulo some performance niche would you care anyway?

It seems configuration management is a graph db query and update matter. Standardize on configuration query language (if necessary) and stop worrying how the damn thing is represented by the config management tool.

Re:What Is Wrong with TOML? by jmaker on Wednesday September 13, 2023 @10:49AM (#37497474)
Depends on your requirements. If your config complexity is getting beyond manageable, the benefit of something more reliable is apparent. Type safety clears lots of common bugs no test suite would be certain to filter out. How complex should your tests get? Do you want to take on that responsibility or rather delegate it to something that provides you certain guarantees? It’s all very subjective in the end.

I run my configs mostly as YAML in Consul and Vault, sometimes in Spring Cloud Config with a git backend. This way I have dynamic config evolution. But I prefer to generate those yaml files from Dhall to avoid unnecessary bugs. After years with Haskell, the syntax is very natural, too.

As for Postgres internals, they do matter if your data set keeps growing.

Xkcd covered standardization. YAML and JSON ASTs are graphs, YAML not necessarily a tree. JSON extensions also support references. As for the ops side, YAML has become a de facto standard, HCL is used with the HashiCorp tools. Nix has its own language.

It’s not about how it’s represented but how you express dependencies across config key nodes. It’s good to avoid repetition and have a syntax linter, a compiler even better. Small static configs are amenable to querying and writing. But you need to separate the writing from the querying the configs. With Dhall you write code to generate the actual config, whether as a Dhall AST or exported to YAML or JSON, with certain correctness guarantees upfront.

Re:What Is Wrong with TOML? by baq on Wednesday September 13, 2023 @10:54AM (#37497549)
> Why not just use a scripting langauge and be done with it?

I want my configuration to be guaranteed to halt. Turns out it's hard to not make anything useful accidentally Turing-complete!

Re:What Is Wrong with TOML? by Hendrikto on Thursday September 14, 2023 @05:22AM (#37506684)
At this point, I‘d rather just use a proper language.
Re:What Is Wrong with TOML? by larschdk on Wednesday September 13, 2023 @07:16AM (#37495202)
INI-files are crap too, as there is no standard. Every program has it's own dialect, and automating around them can be a pain.
Re:What Is Wrong with TOML? by rapsey on Wednesday September 13, 2023 @07:17AM (#37495210)
INI files are toml
Re:What Is Wrong with TOML? by incrudible on Wednesday September 13, 2023 @07:18AM (#37495220)
Exactly, so just use JSON for configuration. This will upset the people that have not yet learned to get over it, but you really need people that got over it.
Re:What Is Wrong with TOML? by BiteCode_dev on Wednesday September 13, 2023 @07:33AM (#37495337)
I do this, but regularly get annoyed with the date, comment, trailing comma, mandatory key quotes, etc
Re:What Is Wrong with TOML? by retzkek on Wednesday September 13, 2023 @12:05PM (#37498554)
Maybe you'd like jsonnet: https://jsonnet.org/

I find it particularly useful for configurations that often have repeated boilerplate, like ansible playbooks or deploying a bunch of "similar-but" services to kubernetes (with https://tanka.dev).

Dhall is also quite interesting, with some tradeoffs: https://dhall-lang.org/

A few years ago I did a small comparison by re-implementing one of my simpler ansible playbooks: https://github.com/retzkek/ansible-dhall-jsonnet

Re:What Is Wrong with TOML? by paulddraper on Wednesday September 13, 2023 @01:12PM (#37499053)
jsonnet is turing complete.

It's configuration with a build step. Which is an option, but that's pretty different than JSON, YAML, TOML, etc.

Re:What Is Wrong with TOML? by BiteCode_dev on Wednesday September 13, 2023 @02:43PM (#37500121)
If I have to use a better format, I will use toml or cue.

The whole point of the parent is that JSON is the Pareto solution, which I agree with.

But it does grind my gear.

Re:What Is Wrong with TOML? by baq on Wednesday September 13, 2023 @09:14AM (#37496309)
JSON is the runner up on the top crap list right below Windows Registry.
Re:What Is Wrong with TOML? by remram on Wednesday September 13, 2023 @09:50AM (#37496723)
No comments means it's not human friendly.
Re:What Is Wrong with TOML? by incrudible on Thursday September 14, 2023 @11:12AM (#37510091)
I would strongly advise against using JSON to configure humans.
Re:What Is Wrong with TOML? by remram on Thursday September 14, 2023 @01:16PM (#37511819)
That's a first, the ol' HN switcharoo?
Re:What Is Wrong with TOML? by BiteCode_dev on Wednesday September 13, 2023 @07:31AM (#37495323)
Let'add another one: CUE

https://cuelang.org

Re:What Is Wrong with TOML? by ianburrell on Wednesday September 13, 2023 @12:17PM (#37498693)
I think it is important to distinguish between human-readable serialization format and human-readable config language. I wish the distinction was made more explicit.

JSON is the champion serialization format. But it is hard to edit config files with missing comments and strict quotes and commas. JSON is great for the API, but configs should be converted from something nicer to JSON. I wonder if it would be good to make the conversion explicit so any format could be used.

Re:What Is Wrong with TOML? by twic on Wednesday September 13, 2023 @01:02PM (#37498949)
Properties files have been fine, i guess since 1995.
Re:What Is Wrong with TOML? by paulddraper on Wednesday September 13, 2023 @01:14PM (#37499073)
HOCON

(But extrapolating, I'm guessing it goes into your crap category.)

Re:What Is Wrong with TOML? by WorldMaker on Wednesday September 13, 2023 @01:48PM (#37499462)
I'm surprised no one has thrown in raw S-Expressions, yet, in this thread. That's an HN perennial favorite. Great at trees, decent at graphs. You can easily go Turing complete or not on the whim of any Lisp at hand and the hammer and forge of macros until your heart's content.
Re:What Is Wrong with TOML? by tikhonj on Wednesday September 13, 2023 @02:03PM (#37499648)
I interned at a company that used an s-expression format as an alternative to JSON and it was great—much better than any mainstream format for config files and human-readable representations for API data. It was great at representing structured data (including tagged variants, so full algebraic data types) and even pretty good for text markup.

It also has best-in-class editor support thanks to paredit :)

The only real downside is the hassle of convincing people to use something weird and non-standard, which is really more a problem with people than with the format.

Re:What Is Wrong with TOML? by eternityforest on Thursday September 14, 2023 @01:00AM (#37505150)
INI is really nice. Anything you can't represent in it, is getting towards not quite just configuration.

I think my ideal format would be INI, with tagged headings so you could do [md:README] and stick a multi line string section in there, or use something like [comment:Module Attributes] to make an embedded docs section.

Either that, or just some other method of embedding multi line keys. Maybe HTML-like tags, so that inside a heading you can do

<my-key> value </my-key>

Re:What Is Wrong with TOML? by PennRobotics on Thursday September 14, 2023 @03:46AM (#37506129)
I have a beef with YAML/TOML/JSON as an inline front matter (header) format for SSG (static site generator) posts, but that's because if I want to save a mostly Markdown SSG post on Github...

1. the post is previewed with Github's dialect of Markdown and not the SSG's (and definitely with none of the inline configuration applied)

2. the preview is still a Markdown document, so you get no benefits of syntax highlighting or auto-formatting w.r.t. the config header (short of opening in Vim and explicitly declaring the filetype or temporarily changing the extension in Github's editor)

3. you HAVE to put trailing spaces in the YAML/TOML/JSON or the preview pane crams everything into an unbroken paragraph

4. there's not a quick preview of how the configuration will parse, just specific workflows (live update, compile single page) that you can test and then modify as needed. This is either in the rich online editor or your own machine and will require console commands and a browser window

5. I still have to know all of the modifiable attributes as well as defaults, which will be in a separate document and probably not in a Ctrl+Space dropdown

-----

For point 5, it would be nice if configuration formats had completions for common editors and/or their own scripts:

* "generate big config file with all possible keys and default values"

* "condense modified config file so it only contains non-defaults (and hope the schema doesnt change hahaha)"

* "suggest a valid fix for a currently invalid config file"

-----

Sure, this all isn't a direct criticism of TOML, but inlining configuration is a great-to-okay idea that is simply poorly executed. It is extremely unfriendly to non-technical users; I can fully understand why someone would pay a few hundred a year for a WYSIWYG templated website builder to just handle everything.