Skip to content

Commit fa9a57e

Browse files
committed
added faq and reordered things
1 parent 71fe171 commit fa9a57e

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

src/_includes/partials/faq.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<section class="kdl-section" id="faq">
2+
3+
## FAQ
4+
5+
#### Why yet another document language?
6+
7+
Because nothing out there felt quite right. The closest one I found was
8+
SDLang, but that had some design choices I disagreed with.
9+
10+
#### Ok, then, why not SDLang?
11+
12+
SDLang is designed for use cases that are not interesting to me, but are very
13+
relevant to the D-lang community. KDL is very similar in many ways, but is
14+
different in the following ways:
15+
16+
* The grammar and expected semantics are [well-defined and specified](https://github.com/kdl-org/kdl/blob/main/SPEC.md).
17+
* There is only one "number" type. KDL does not prescribe representations.
18+
* Slashdash (`/-`) comments are great and useful!
19+
* I am not interested in having first-class date types, and SDLang's are very
20+
non-standard.
21+
* Values and properties can be interspersed with each other, rather than one
22+
having to follow the other.
23+
* KDL does not have a first-class binary data type. Just use strings with base64.
24+
* All strings in KDL are multi-line, and raw strings are written with
25+
Rust-style syntax (`r"foo"`), instead of backticks.
26+
* KDL identifiers can use UTF-8 and are much more lax about symbols than SDLang.
27+
* KDL does not support "anonymous" nodes.
28+
* Instead, KDL supports arbitrary identifiers for node names and attribute
29+
names, meaning you can use arbitrary strings for those: `"123" "value"=1` is
30+
a valid node, for example. This makes it easier to use KDL for
31+
representing arbitrary key/value pairs.
32+
33+
#### Have you seen that one XKCD comic about standards?
34+
35+
Yes. I have. Please stop linking me to it.
36+
37+
#### What about YAML?
38+
39+
YAML is a great, widespread language. Unlike KDL, which is node-based (like
40+
XML or HTML), it's based on map and array data structures, which can provide
41+
an easier serialization experience in some cases.
42+
43+
At the same time, YAML can be ambiguous about what types the data written into
44+
it is. There's also a persistent issue where very large YAML files become
45+
unmanageable, especially due to the significant indentation feature.
46+
47+
KDL is designed to avoid these particular pitfalls by always being explicit
48+
about types, and having clearly-delimited scope (and the ability to
49+
auto-indent/auto-format). Syntax errors are easier to catch, and large files
50+
are (hopefully!) much more manageable.
51+
52+
#### What about JSON?
53+
54+
JSON is a great serialization language, but it can be very difficult to use as
55+
a human configuration language. This is largely due to its very specific, very
56+
strict syntax, as well as its lack of support for comments.
57+
58+
KDL, on the other hand, has great comment support, and has a much more
59+
forgiving syntax without being so flexible as to allow certain classes of
60+
unfortunate mistakes. It also has much more flexibility around how to
61+
represent data.
62+
63+
#### What about TOML?
64+
65+
It nests very poorly. It doesn't fare well with large files.
66+
67+
#### What about XML?
68+
69+
XML is actually pretty fantastic, and has long been a standard for data
70+
exchange across many industries. At the same time, XML is known to be very
71+
verbose, and editing it involves writing (and updating) matching tags. Another
72+
large pitfall with XML is its lack of direct support for arbitrary string
73+
key/value pairs, so what would be a simple `foo: x` in some languages has to
74+
be represented as `<entry name="foo" value="x" />` or something similar. XML
75+
also functions great as a **markup** language. That is, it is easy to
76+
intersperse with text, like HTML.
77+
78+
KDL, just like XML, is a node/element-based language, but with much more
79+
lightweight syntax. It also adds the ability to apply anonymous values
80+
directly to a node, rather than as children. That is, `nodename 1 2 3` instead
81+
of `<element><child>1</child><child>2</child>(etc)</element>`. This can make
82+
it much more manageable and readable as a human configuration language, and is
83+
also less verbose when exchanging documents across APIs!
84+
85+
Finally, KDL is **not** a markup language. XML or HTML do a much better job of
86+
"marking up" a text document with special tags, although KDL can still be
87+
useful for templating engines that want to be more strict about text
88+
fragments.
89+
90+
</section>

src/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ title: KDL - KDL Document Language
88
</header>
99

1010
{% include partials/description.md %}
11-
{% include partials/design-and-discussion.md %}
12-
{% include partials/design-principles.md %}
1311
{% include partials/implementations.md %}
1412
{% include partials/overview.md %}
13+
{% include partials/design-and-discussion.md %}
14+
{% include partials/design-principles.md %}
15+
{% include partials/faq.md %}

0 commit comments

Comments
 (0)