The KDL Document Language
kdl.dev
kdl.dev
I'm the author of the Java KDL library, https://github.com/hkolbeck/kdl4j. I'm currently overwhelmed by other things and unable to do the work to get it up to the 1.0.0 spec. I'm looking for folks willing to help me. DM me on Twitter at the same name if you're interested.
(of the strong programmers i know, each refuses to have anything to do with twitter.)
I'd be interested to know what the author thinks about RON[0], it's not quite the same but also has some nice properties and wants to be a replacement for JSON (yes this is more one for XML or JSON, but still).
Sometimes I wonder if all those formats would never have got invented if JSON had just allowed comments and trailing commas in the first place. While there's JSON5[1] now, it just has not the same level of native (ecosystem) support as JSON has.
[0]: https://github.com/ron-rs/ron
[1]: https://json5.org/
Why yet another document language?: "Because nothing out there felt quite right."
Sometimes looking at code (my code) or platforms, frameworks etc, this "does it feels right" plays big part in my decision to use/like it.
* '(1 #+nil 2 3)
(1 3)[1] apparently I didn't edit this in fast enough but wow I have even less interest in semantic arguments about what is and isn't a markup language.
> Finally, KDL is not a markup language. XML or HTML do a much better job of "marking up" a text document with special tags, although KDL can still be useful for templating engines that want to be more strict about text fragments.
Sure, editors often have shortcuts, but then undoing them is often a pain and sometimes I'm editing something in a really basic editor and it'd be nice to just let the compiler to it.
It seems like it would be annoying to write this directly, like how do you make a word bold or italic? How do you make a class of hyperlink that's a different color (e.g. internal links vs. external)? HTML is OK but not fun to write directly -- I'm not sure that KDL is an improvement. You would still want something like Markdown.
On the other hand it could be better for tables, which are awkward in HTML. But I'd like to see how that works.
In summary:
- XML/HTML: better when you have more text than data. Good for docs, awkward for tables.
- JSON: better when you have more data than text. Good for web API request and response, awkward for docs (e.g. do you want to write markdown or HTML inside double quotes?). OK for config files but awkward because it's a strict format.
> Finally, KDL is not a markup language.
https://github.com/kdl-org/kdl/blob/main/examples/website.kd...
It seems to be straddling documents and configuration, which in my experience makes for a lot of awkwardness.
This part seems to be a symptom of that:
There are two specifications for writing KDL that can be losslessly translated between it and JSON or XML. These specifications define a stricter subset of KDL that, even if NOT entirely idiomatic, is still valid and fits into the data models of the other two languages: (emphasis mine)
> The very first example is a document with metadata like title, author, etc. It's called a "document language".
Static sites generators often have content in markdown, but I also saw quite some use of YAML or JSON. > It seems to be straddling documents and configuration, which in my experience makes for a lot of awkwardness.
It seems to be for structured data, that can be both a document of some sorts or a configuration; just like YAML/JSON/XML is used for both. > There are two specifications for writing KDL that can be losslessly translated between it and JSON or XML.
> These specifications define a stricter subset of KDL that, even if NOT entirely idiomatic, is still valid and fits into the data models of the other two languages: (emphasis mine)
Note that the author means two separate, additional specifications about how to losslessly translate (iow. convert) between KDL and JSON or XML, not that the actual KDL spec has provisions for reading JSON/XML as KDL. I mean, FWICT some JSON file may parse though, but it's not like YAML, which is an actual superset of JSON; now _that_ adds awkwardness.One can also create a spec to transform JSON into XML, that does not mean it has anything directly to do with the XML spec.
I rather see this as effort to make it easier to switch to KDL, if one finds its characteristics nice(r).
[1] EDIT: to be clear here, I meant to say it has a specification. I'm guessing your handbaked language won't have.
Message boards are message boards. You can't take them seriously, including this one.
I want my open source project to be able to be used in commercial applications, and don't want any of my dependencies' licenses to restrict that.
[1]: https://github.com/kdl-org/kdl-rs/blob/87f836134c1d901ff5ce6...
Just going through the section for why they think it beats YAML:
> YAML can be ambiguous about what types the data written into it is.
If you're worried about data types, that sounds like a job for a proper data storage format rather than putting it into a configuration file, no?
> There's also a persistent issue where very large YAML files become unmanageable, especially due to the significant indentation feature.
That sounds like a poorly designed configuration setup. If you've got a nested config that complex, by my reckoning, it should be reorganized into flatter data structures or broken down into more specific configuration files regardless of what the format is.
>YAML is a great, widespread language. Unlike KDL, which is node-based (like XML or HTML), it's based on map and array data structures, which can provide an easier serialization experience in some cases.
Saying that processing node-based formats is more difficult in 'some cases' is a particularly charitable take, especially when they're touting their ability to handle very large, complex configurations.
> KDL is designed to avoid these particular pitfalls by always being explicit about types, and having clearly-delimited scope (and the ability to auto-indent/auto-format). Syntax errors are easier to catch, and large files are (hopefully!) much more manageable.
It seems like it adds significant complexity over YAML to mitigate abuse of YAML... but wouldn't it just be better to do a better job using YAML?
I do tend to be biased towards conforming to the usage practices of existing tools rather than adopting new tools for edge cases or minor conflicts because learning new tools tends to have a slightly higher cognitive toll for me than some others— but as a general rule, I don't see a problem with only switching tools because you have a problem that's significantly more difficult or less efficient to solve with the old tool.
Maybe there's some really clear use cases that aren't obvious to me for whatever reason.
After dealing with a bunch of really hairy, complex, node-based data processing for a few years, I'd sooner roll around in a dusty sandbox with my eyes taped open than purposefully invite that into my life again... but if I suppose if you're doing something that dumb in your config files then the config format isn't the problem, anyway. Cheers.
YAML isn’t just for config. It’s also a serialization format. If your internal data structures are deeply-nested, then the YAML serialization of them will also (properly) be deeply-nested.
Sometimes you need to hand-edit some data in a multi-megabyte YAML-serialized file. It’s possible, but it’s kind of awful. Editing a multi-megabyte KDL-serialized file sounds like it might be slightly less awful.
(Maybe I’m weird, but I see this format as being close to a textual analog of https://en.wikipedia.org/wiki/Interchange_File_Format, as used/inherited by file formats like AIFF, PNG, etc. Maybe picturing a PNG file or the like encoded in this format might make it clearer what the author is going for?)
On the complexity axis I think you're talking about, yes, having clear scopes and no ambiguity about whether something is a string means there are more bits of syntax to type, but I don't think that adds complexity. JSON has more curly braces and quotes but it is a much simpler and much more reliable format than YAML. KDL is the same.
KDL does not "add significant complexity over YAML" in really any sense. The KDL specification is 1/10th the size of YAML's. Being extraordinarily complex and impossible to fully implement is is what YAML is famous for.[0] Asking people to do a better job writing YAML is a tough ask when even computers can barely do it correctly.
> If the element contains mixed text and element children, the text can be encoded as a KDL node with the name - with a single string unnamed argument. For example, the XML
<span>some <b>bold</b> text</span>
> can be encoded as span { - "some "; b "bold"; - " text" }.Quick said-contras:
Q: "Another markup/config language?" A: Yes. We actually do get (slowly) better at solving already-solved problems. Evolution of spec does happen and is important. Steady refinement and reflection on past work just is progress.
Q: "OK, but is it worth the mental clutter and cognitive load of an additional standard/dependency/format?" A: That's for the market and community to decide together. Example: Time was, Markdown was a bizarre hobby format and most work happened in XML or LaTeX or Wiki (or, gasp, Perldoc). But Markdown proved better, more sensible; so Markdown won.
Q: "Why not YAML?" A: Am I the only old here who remembers the era of YAML security bugs? Like, it was like the Sendmail Bug Era, but worse, because it was in everything. YAML, like Perl, is easy to read, but hard to reason about; and that makes it a hazard. These days, we have YAML libs and practices we regard as known-good, but I still trust it about as much as I trust \.doc(x?) or \.pdf, or some weird execv() involving ImageMagick. It's unclean. Sorry, not sorry.
KDL is solid and I'm a fan.
Two things I particularly enjoy:
- Self-closing blocks.
- Easy parsing.
rome name="Rome" founded="753BC"(source=foobar) {
child ...
}Unfortunately I don't quite see it as a replacement for Jsonnet (or Dhall, etc) in terms of writing extremely laborious Kubernetes/Terraform/etc config by hand. It doesn't seem very easy to embed a functional KDL-generating language in KDL. I sat down and tried to imagine what this would be like and couldn't make it connect. Maybe someone else can give this a shot, there are devops folks out there that need saving from YAML. Part of the problem for KDL as a replacement for these is that its mapping to JSON/YAML is a bit awkward, whereas XML is actually pretty close. That's presumably why Kat called it their Document Language. So I expect if it catches on it will be in greenfield projects or XML revamps.
The only syntactic difference I see with GraphQL is the lack of parenthesis around arguments and the existence of anonymous arguments.
It’s painful to go through.
this looks interesting
Aha, cute pun! :)
and the lang itself looks quite nice tbh
Also yes, I'm aware the author states:
>Have you seen that one XKCD comic about standards?
>Yes. I have. Please stop linking me to it.
To which I say: You shouldn't have created a new standard if you didn't want to be linked to the xkcd. Any annoyance is self inflicted, and you've weaponized the internet against yourself.
Honestly, if the internet had been around when the screwdriver was invented, the Hacker News commenters of the time would have been linking to XKCD 927 along with snide comments about how hammers and wrenches already exist.
Rolls eyes.
Screwdrivers scale!
Screwdrivers are scalable, idempotent and functional.
Can't believe you are serving 100 villagers with hammers. Hammers make everything look like a nail. And it's impossible to make comments with wrenches.
In my mind, copyleft licenses applied to infrastructural projects like kdl-rs prematurely limits their adoption and promotes the development of alternatives with more permissive licensing, since the spec is released under a Creative Commons license [2].
[1]: https://github.com/kdl-org/kdl-rs/blob/87f836134c1d901ff5ce6...
[2]: https://github.com/kdl-org/kdl/blob/785abebfc507ff6b7bdeac07...