5 ms·
So... what are the good alternatives to yaml? For quite some time I thought toml, but the way you can spread e.g. lists all over the document can also cause so
by Kostarrr 1y ago
So... what are the good alternatives to yaml?
For quite some time I thought toml, but the way you can spread e.g. lists all over the document can also cause some headaches.
Dhall is exactly my kind of type fest but you can hit a hard brick wall because the type system is not as strong as you think.
- endgame 1y agoI wish I had a good answer for you. I've been dissatisfied with Dhall, Nickle, Cue, and possibly others. Dhall's type system is both too strong (you have to plumb type variables by hand if you want to do any kind of routine FP idioms) and too weak (you can't really _do_ much with record types - it's really hard to swizzle and rearrange deeply nested records). On top of that, the grammar is quite difficult to parse. You need a parser that can keep several candidate parses running in parallel (like the classic `Parser a = Parser (String -> [(a, String)])` type) to disambiguate some of the gnarlier constructs (maybe around file paths, URLs, and record accesses? I forget). The problem with this is that it makes the parse errors downright inscrutable, because it's hard to know when the parse you actually intended was rejected by the parser when the only error you get was "Unexpected ','". Oh, and you can't multiply integers together, only naturals. Maybe Nix in pure eval mode, absurd as that sounds? I think the best thing for tools to do is to take and return JSON (possible exception: tools whose format is simple enough for old-school UNIX-style stdin/stdout file formats). Someone will come up with a good functional abstraction over JSON eventually, and until then you can make do with Dhall, YAML, or whatever else.
- ruuda 1y ago> Maybe Nix in pure eval mode, absurd as that sounds? It doesn’t sound absurd, it’s pretty nice. What do you think about https://rcl-lang.org https://rcl-lang.org?
- rswail 1y agoJust been reading the docs, I like it :) Gonna have to set aside some time to play with it compared to HCL where I spend a lot of time.
- cousin_it 1y agoHow about textproto? And the proto definition gives the schema.
- lazystone 1y agoNo one mentioned HashiCorp HCL so far, though it's really a shame that it didn't get much traction...
- rswail 1y agoHCL is ok except for the lack of user defined functions which leads to clumsy tricks with nested comprehensions. Given its general use around infrastructure, it'd be nice if it had IPv4 and IPv6 addresses as native types that get parsed.
- mrgaro 1y agoHCL is so annoying as it tries so much to prevent user to "do too complex things" and thus it doesn't have proper iterators other similar concepts, which would be very useful when defining infrastructure as xode. This has resulted bunch of hacks (such as the count directive on terraform) so that the end result is a frustrating mess.
- bmacho 1y agoWhat about KDL (https://kdl.dev/ https://kdl.dev/) or Pkl (https://pkl-lang.org/ https://pkl-lang.org/)?
- simonask 1y agoKDL is really, really nice. And lightweight.
- Ajedi32 1y agoFor configuration I dislike the XML object model KDL is built around. It needlessly complicates things to have two different incompatible ways (properties and children) of nesting configuration keys under an element. Pkl seems syntactically beautiful and powerful, but having types and functions and loops makes it a lot more complicated than the dead-simple JSON data model that YAML is based on.
- speed_spread 1y agoIn JSON I often end up recreating XML attributes equivalent for metadata fields and using custom prefixes to differentiate those fields from actual data. I find it's nice the data/metadata separation at the language level.
- Ajedi32 1y agoCan you give an example of metadata you would put in a config file that isn't configuration and isn't a comment?
- speed_spread 1y agoMetadata is less useful in a config file since it's all static data. But for something more dynamic (messaging, persistence) attributes can be used for Time-To-Live, object class, source, signature, etc.
- speed_spread 1y agoThe article mentions > A simple subset of yaml Which already exists and is called StrictYAML. It's just strings, lists and dicts. No numbers. No booleans. No _countries_. No anchors. No JSON-compatible blocks. So, essentially it's what most of use think as being proper YAML, without all the stupid/bad/overcomplicated stuff. Just bring your own schema and types where required. https://hitchdev.com/strictyaml/ https://hitchdev.com/strictyaml/
- pbronez 1y agoThe author of this article created RDL: > RCL is a domain-specific language for generating configuration files and querying json documents. It extends json into a simple, gradually typed, functional programming language that resembles Python and Nix. https://github.com/ruuda/rcl https://github.com/ruuda/rcl https://rcl-lang.org https://rcl-lang.org