There's parsers for a bunch of languages now, including a really nice format-preserving parser for Rust that I released a short while ago: https://crates.io/crates/kdl
@cr1901 not just comments, it has *slashdash* (/-) comments, which are _structural_ comments, instead of line-based:
@zkat Holy shit this just blew my mind. I went from never ever having had this idea straight to "why does not every languages do this??"
@zkat I've always used // and /* comments to distinguish between code comments and commented out code. (and wished they had more built in semantics around that concept) /- comments are a way superior method to achieve the same goal.
@zkat Realistically, I'm stalling working on something I don't want to work on.
But I finally caved and wrote my own build system (err ninja generator) and am thinking of using KDL as the config file that becomes a ninja file.
@zkat I really love that for replacing MSBuild files... XML is just so annoyingly verbose for that application.
@zkat nice, thank you! Amazing work here! I will consider using this at work to replace some huge JSON files we have to edit manually…
@zkat hah yeah, cool language, during the GH Actions alpha it did act a lot like this https://github.com/orta/actions/blob/f3f2cab80006418d8ef452848149b8550ba95002/.github/danger-swift.workflow#L1
How possible would it to build a transpiler for this? You could then write your CI configs with KDL and "compile" them into YAML, JSON or whatever format your CI accepts. I think that would be cool!
@heikkiket one for a specific purpose? Easy. A generalized one? Hard.
It’s very very easy to convert kdl<->xml
The same is not true for yaml and json. They have different semantics
@ariadne CUE looks like a schema/validation language for validating JSON/yaml? That's pretty much completely orthogonal to KDL itself (which doesn't even have JSON/YAML semantics)
@zkat Would you say it is worth a look trying to replace Gtk UI files with this? https://github.com/DiNoScore/DiNoScore/blob/master/res/viewer.glade
@zkat One weird weekend hack I've been playing with is a small cmdline tool that looks for a `context.kdl` file with environment variables, conda environments, etc and applies those when cd'ing into a directory. Basically `.env` files taken to their logical extreme...
@zkat thanks for the reminder, last time I tried it, I ended up bouncing off and reverting to JSON mostly because I already had a mental model for what those docs look like.
I found https://github.com/kdl-org/kdl/tree/main/examples just now after you posted a couple screen shot examples and realized a lot of what I wanted was this. Now I just need to build a language type to document munger in my mental model. Going to try replacing some of my config in my 8-bit repository with kdl again this weekend.
@zkat anyway, just wanna say thanks for building cool stuff, it always challenges my tech mental model. Whether it's config format now or lisp stuff in our early friendship, or all the stuff between. Following your projects has made me a better engineer.
this looks pretty awesome. have you checked out UCL by any chance? i've found it to work quite well for freebsd, and seems to share some of the same concepts you note.
having said that - i'm all for more well thought out config formats that aren't yaml/json/xml
@nomadlogic this looks very strange and inconsistent to me? Also, it doesn't look very different from JSON or YAML to me.
i suspect the reason that it certainly does resemble YAML/JSON might be due to it's inherent ability to parse (and emit) those serialization formats.
so maybe it's nothing like what your working on - or the total opposite of your goals 😂
@nomadlogic yeah you can’t 1:1 convert between kdl and JSON/Yaml unless you follow specific patterns. It’s not meant for that.
@zkat I'm convinced that there should be three types of config languages:
- Basic: StrictYaml (essentially string-only) / ini / .env
- Sophisticated: KDL/etc
- Programmatic: HCL
On the internet, everyone knows you're a cat — and that's totally okay.