top | item 45345789

(no title)

Kostarrr | 5 months 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.

discuss

order

endgame|5 months ago

I 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|5 months 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?

bmacho|5 months ago

What about KDL (https://kdl.dev/) or Pkl (https://pkl-lang.org/)?

Ajedi32|5 months ago

For 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.

simonask|5 months ago

KDL is really, really nice. And lightweight.

lazystone|5 months ago

No one mentioned HashiCorp HCL so far, though it's really a shame that it didn't get much traction...

mrgaro|5 months ago

HCL 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.

rswail|5 months ago

HCL 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.

speed_spread|5 months ago

The 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/

pbronez|5 months ago

The 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://rcl-lang.org

cousin_it|5 months ago

How about textproto? And the proto definition gives the schema.