Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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.


> 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?


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


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


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.


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


Can you give an example of metadata you would put in a config file that isn't configuration and isn't a comment?


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


KDL is really, really nice. And lightweight.


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


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.


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.


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/


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


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: