9 ms·
The KDL Document Language
- howenterprisey 5y agoI really like the /- ("slashdash") comments. Seems like they did a lot of things right! I might use this in projects.
- hoytech 5y agoMe too! I sometimes do this in lisp, to comment out the following expression: * '(1 #+nil 2 3) (1 3)
- chubot 5y agoNice doc, but I feel like it's confusing documents like XML/HTML and tree-structured data like JSON. 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.
- chrismorgan 5y agoRight near the end: > Finally, KDL is not a markup language.
- scoopertrooper 5y agoHere's an example of how a HTML page would be presented. https://github.com/kdl-org/kdl/blob/main/examples/website.kdl#L27 https://github.com/kdl-org/kdl/blob/main/examples/website.kd...
- xixixao 5y agoIt actually looks pretty similar to GraphQL but without parens around argument lists. I wonder whether the author looked at it as well (might be interesting to compare).
- xixixao 5y agoWhich reminds me, the doc doesn’t mention typeaheads. The ability to provide suggestions should be one of the considerations when designing a new syntax.
- laumars 5y agoOh wow. That’s actually surprising readable. I’m genuinely impressed.
- rubyist5eva 5y agoreminds me of slim templates, but not just for Ruby http://slim-lang.com/ http://slim-lang.com/
- loic-sharma 5y agoThis isn't meant to replace HTML. I see it as a better language for configs. JSON lacks comments. YAML also has problems: https://noyaml.com/ https://noyaml.com/
- chubot 5y agoThe very first example is a document with metadata like title, author, etc. It's called a "document language". 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)
- tlamponi 5y ago> 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).
- chrsig 5y agoObligatory xkcd: https://xkcd.com/927/ https://xkcd.com/927/ 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.
- andolanra 5y agoThis isn't a unifying standard, which is what the XKCD comic is about. It's not attempting to take other standards and develop the One To Rule Them All—you know, like the first panel of the comic describes—but rather building a different tool that's a better fit for some specific use-cases. 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.
- philipswood 5y agoHammers, wrenches! 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.
- estebarb 5y ago"A wheel? Don't be silly, how are you going to add wheels to a horse?" (Prehistoric HN commenter)
- hbeckpdx 5y agoHi! I'm the author of the Java KDL library, https://github.com/hkolbeck/kdl4j 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.
- jjtheblunt 5y agothank you for this very cool effort; what if the folks able to help are those who shun twitter? (of the strong programmers i know, each refuses to have anything to do with twitter.)
- hbeckpdx 5y agoThey can email hskolbeck at gmail :)
- chefandy 5y agoHmm... Not really sure I get what problem this schema is the best solution for. It seems like the author was more interested in implementing a model they felt was more conceptually sound than other solutions, but aren't solving any significant problems, and don't seem to have any big functional improvements over more established contenders. 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.
- hbeckpdx 5y agoI felt similarly when I first saw it, but I saw that there was no java impl, and I'd been looking for a project, so I wrote one. I've been playing with it for more than 6 months and I think it's better than YAML in a number of ways. The syntax is very clear and mostly simple and the noted ability to autoformat is no small thing. I think it aims for a niche, and hits its target pretty well.
- heluser 5y agoRefenrecing the site “What about HOCON?”
- sieve 5y agoI would like to see a document format based on s-expr catch on. I briefly worked on one[1] just enough for it to support the features needed for another project. Two things I particularly enjoy: - Self-closing blocks. - Easy parsing. [1] https://github.com/s-i-e-v-e/sxml https://github.com/s-i-e-v-e/sxml
- gnulinux 5y agoI have no idea what people are complaining about in this thread. I find projects like this genius. I love making programming languages and I hate hate hate writing parsers, yet I enjoy experimenting with different syntax. Stuff like this is very convenient because you can just import your code as document, use path language to extract data, and schema language to apply basic checks. Not only is this thing standardized[1], it's implemented in your favorite language (Rust, Python, Java whatever). [1] EDIT: to be clear here, I meant to say it has a specification. I'm guessing your handbaked language won't have.
- chefandy 5y agoWhen my projects are posted publicly, I like attaboys, but I need constructive criticism. Asking pointed questions and questioning purported inconsistencies is not complaining.
- void_mint 5y agoCriticism given by those that do not align with the core goals/userbase of a project is not constructive. Giving criticism on something you don't intend to/wouldn't use is just complaining.
- jcelerier 5y agoI disagree, there's always the chance that there is a nugget of useful knowledge in there. I'd rather go through 100s of criticisms than miss it.
- cormacrelf 5y agoFor some perspective, this HN thread is much, much better than the Reddit post from yesterday. Sure, there were a couple of good points hidden in the rubble, but lordy it was bad. Cruel, even. The main author has taken a break (and fair enough) so you probably won't see them around today.
- 5y ago
- sandreas 5y agoIs this related to https://kaitai.io/ https://kaitai.io/?
- deleted 5y ago[deleted]
- stormbrew 5y agoI have pretty much no interest in another markup language (or whatever we're calling these sorts of things today[1]) but I really want the slashdash comment style in every language I use now, that's an incredible idea. [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.
- tlamponi 5y agoThe author specifically mentions at the end that they do not mean KDL to be 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.
- afranchuk 5y agoYeah tbh I don't know why syntax commenting isn't more common; when I wrote a language with s-exprs one of the earliest things I did was add a comment form to comment out an expression. And _especially_ in s-exprs it's almost trivial to add! Really don't understand why we don't see it more.
- mro_name 5y agoso do(n't) I.
- floppydisc 5y agoWhy is the slashdash comment style an incredible idea?
- stormbrew 5y agobecause commenting out multiple lines of code in most languages is tedious and involves me doing work the compiler already knows how to do in my head. 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.
- tlamponi 5y agoLooks interesting enough to put it on my "to evaluate/play-around" pile. 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 https://github.com/ron-rs/ron [1]: https://json5.org/ https://json5.org/
- d--b 5y agoGo for it KDL, I really want a better standard for this. Anyone with some dev experience has done the XML => Json => Yaml => “screw it I’ll do my own” cycle. It’s painful to go through.
- nikolay 5y agoYeah. What's next to follow? The whole format ecosystem - only KDL, i.e. all the equivalents of XPath, XSLT, XQuery, XML Schema, libraries, and modern re-envision of other tools such as jq and JMESPath...
- wodenokoto 5y agoThey mention xml quite early but bury how you’d do markup inside a text. Basically you can’t do it, but there is a convention to work around it. > 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" }.
- cormacrelf 5y agoI'm pretty sure that's invalid KDL, despite appearing in the XML-in-KDL document. Both the grammar and kdl-rs appear to require a trailing semicolon before the close brace. I think this might be a bug in one of the specs.
- MarkLowenstein 5y agoI've long made half-hearted stabs at creating what I call "NFML", a.k.a. "No Markup Language". My vision is incredibly similar to this, so I wish you luck! I believe the future resembles KDL.
- severak_cz 5y agoWhat's the use case of this? It's for configs, documents or what?
- cormacrelf 5y agoI think anything you would normally write a schema for, and edit by hand. It does actually come with a schema language too, embedded in KDL, based on JSON-schema. I think it would be a great syntax for something like CSL (Citation Style Language, something I work with); not a document, no actual content, but free-flowing, recursive, needs a schema, and is edited by non-programmers. There's a lot of talk in CSL-land about graphical editors because XML is just too hard, but graphical editors are also too much effort to build. Someone once suggested based on general facts (lighter, etc) about JSON that CSL should switch input language to JSON -- that would have been a disaster, JSON is terrible for this. (And the CSL project wouldn't change its spec dramatically and unnecessarily.) But KDL seems good for that kind of thing. 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.
- anentropic 5y ago> The language is based on SDLang Aha, cute pun! :) and the lang itself looks quite nice tbh
- rawoke083600 5y agoI like it :) As "precise" and "analytical" we like to think we are (well I least). I can fully agree with the FAQ section; 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.
- deknos 5y agoHonest question: are there document languages for ticket systems and/or process/project plans? like gant diagrams? no tex code, but real DSLs? this looks interesting
- xonix 5y agoIf I've got you right, then https://plantuml.com/en/gantt-diagram https://plantuml.com/en/gantt-diagram
- qwerty456127 5y agoWhy ever allow non-property text in a node? Isn't this an example of needless complexity?
- mactavish88 5y agoI'd love to understand why all the advertised implementations have permissive licenses except for the Rust implementation, which is released under the Parity Public License 7.0.0 [1]? This seems to be as restrictive as the GPL, no? 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/87f836134c1d901ff5ce6c81d2a0e38231d2972b/LICENSE.md https://github.com/kdl-org/kdl-rs/blob/87f836134c1d901ff5ce6... [2]: https://github.com/kdl-org/kdl/blob/785abebfc507ff6b7bdeac07dcd384ac7a0d0c49/LICENSE.md https://github.com/kdl-org/kdl/blob/785abebfc507ff6b7bdeac07...
- undoware 5y agoI'm quite fond of KDL and intend to use it in a future project. 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.
- crubier 5y agoThis is also close enough to GraphQL that it could replace it. The only syntactic difference I see with GraphQL is the lack of parenthesis around arguments and the existence of anonymous arguments.
- nikolay 5y agoIt's pretty close to HashCorp's HCL, actually.
- rambojazz 5y agoDoes it support multilevel properties (ie. properties about properties)? What I mean is something like this rome name="Rome" founded="753BC"(source=foobar) { child ... }