6 ms·
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 Pur
by baq 3y ago
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.
- ducktective 3y agoNickel[1] maybe? Though I'm not sure about "for humans" part :) [1]: https://github.com/tweag/nickel https://github.com/tweag/nickel
- RedNifre 3y agoTry edn: https://learnxinyminutes.com/docs/edn/ https://learnxinyminutes.com/docs/edn/
- masklinn 3y agoI 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.
- dkersten 3y agoI 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.
- jmkr 3y agoWhy 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.
- dkersten 3y agoI 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.
- dkersten 3y agoI 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 https://github.com/weavejester/integrant
- eternityforest 3y agoToo 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
- conradludgate 3y agoMaybe kdl[0]? It's a document language somewhere in between xml and yaml without all the crap of either IMO [0]: https://kdl.dev/ https://kdl.dev/
- alpaca128 3y agoI 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.
- jmaker 3y agoDhall is superb, https://dhall-lang.org https://dhall-lang.org
- 37469920away 3y agoThanks 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 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.
- jmaker 3y agoDepends 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.
- larschdk 3y agoINI-files are crap too, as there is no standard. Every program has it's own dialect, and automating around them can be a pain.
- rapsey 3y agoINI files are toml
- incrudible 3y agoExactly, 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.
- BiteCode_dev 3y agoI do this, but regularly get annoyed with the date, comment, trailing comma, mandatory key quotes, etc
- retzkek 3y agoMaybe you'd like jsonnet: https://jsonnet.org/ 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 https://tanka.dev). Dhall is also quite interesting, with some tradeoffs: https://dhall-lang.org/ 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 https://github.com/retzkek/ansible-dhall-jsonnet
- paulddraper 3y agojsonnet is turing complete. It's configuration with a build step. Which is an option, but that's pretty different than JSON, YAML, TOML, etc.
- BiteCode_dev 3y agoIf 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.
- baq 3y agoJSON is the runner up on the top crap list right below Windows Registry.
- remram 3y ago
- BiteCode_dev 3y agoLet'add another one: CUE https://cuelang.org https://cuelang.org
- ianburrell 3y agoI 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.
- twic 3y agoProperties files have been fine, i guess since 1995.
- paulddraper 3y agoHOCON (But extrapolating, I'm guessing it goes into your crap category.)
- WorldMaker 3y agoI'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.
- tikhonj 3y agoI 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.
- eternityforest 3y agoINI 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>
- PennRobotics 3y agoI 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.