-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
It is a better option for certain purposes. JSON has many advantages. It's simple, easy to learn, easy to parse, widely adopted and available on every platform that has a JavaScript parser because it is a perfect subset of the language. In many cases it is good choice as a lingua franca data description language. That being said, KD has a number of advantages for scientific apps, finance apps, rules engines and other domains that require intricate data structures, benefit from easy expression of higher level types, or need stronger type validation.
KD is terser, more expressive and easier to read than equivalent JSON. Let's look at a simple example of a version range:
JSON
{
"name: "widget",
"lowerVersion": [2, 3, 1, "beta", 2],
"upperVersion": [5, 2, 0, "RC"]
}
KD
widget 2.3.1-beta-2 .. 5.2.0-RC
Not only is the KD version easier to read, but it produces a single tag "widget" with a Range<Version> type for the value. Range<Version> is a Ki (KD's base library) type ported by all compliant Ki implementations. They either provide a Ki Range type or map to a suitable existing type if one is available.
Additional advantages include:
- Higher order portable types such as Range, Date, LocalDateTime, ZonedDateTime, Duration, Version, List and Map
- A modern type system with support for nullable and non-nullable types, generics and validators
- Sophisticated, easy to use schema
- Support for Quantities with SI Units of Measure
- Stronger validation: The parser maps literals to 20 types, each with their own validators.
- Higher precision numbers: Ki's Decimal type is 128 bits. This is often necessary in financial and scientific domains.
- XML-style namespaces
No. XML is an excellent format for marking up documents, describing metadata, mixing tags in free form text, and many other applications.
XML is also commonly used for properties files, configuration files, and object serialization. For these purposes, KD offers a terser and more perspicuous syntax. KD is type aware and allows data structures such as ranges, lists, maps, trees and grids to be easily represented.
Lets look at a snippet from a configuration file represented in both languages.
XML
<path id="prog.src">
<pathelement path="${src.dir}" />
<pathelement path="${res.dir}" />
<pathelement path="${external.src.dir}" />
</path>
<target name="prog.tests" depends="prog.build" echo="true">
<java classname="org.ikayzo.sdl.PackageTests" failonerror="true" dir="${basedir}/test" fork="true">
<arg value="-d" />
<arg value="${basedir}/test" />
</java>
</target>
KD The KD equivalent is shorter, more readable, and type-aware:
path prog.src elements=["${src.dir}" "${res.dir}" "${external.src.dir}"]
target prog.tests depends=prog.build echo=true {
java org.ikayzo.sdl.PackageTests failonerror=true dir="${basedir}/test" fork=true \
args=["-d" "${basedir}/test"]
}
It does. Because clarity and readability (by humans and computers) is a design goal, KD has its own format, but it also supports ISO-8601 representations.
ISO-8601 | KD |
---|---|
2021-05-21T05:30:15Z | 2021/5/21 @5:30:15-Z |
2021-05-21T05:30:15-08:00 | 2021/5/21 @5:30-8 |
2021-05-21T05:30:00-08:00[America/Los_Angeles] | 2021/5/21 @5:30-US/PST |
Notes:
- Ki ZonedDateTime's can also optionally include zero padding.
- The space between date and time is optional.
- Ki DateTime types have nanosecond resolution.
- Ki ZoneIDs can be specified by offsets or short common names called KiTZ, which are unambiguous thanks to the inclusion of a country code.
ISO-8601 | KD |
---|---|
PT5H | 5h |
PT29H30M15.412S | 1day:5:30:15.412 |
Note:
- Ki Durations have nanosecond resolution.
- The time unit is required for durations including a
day
component. All others are optional (i.e.1day:5:30:15.412
or1day:5h:30min:15.412s
)
Because this isn't 1990. Everything in KD is UTF-8. UTF-8 can encode every code point in Unicode and is used by 95+% of everything. If you aren't using UTF-8 and you aren't working on the internal representation of Strings in memory for some type of runtime system you are doing it wrong.
KD-JVM uses new language features introduced in Java 11. The included binaries will only work with the Java 11 JVM or later.
KD-.NET requires C# 5.0. There are currently no plans to provide support for earlier versions, but if you would like to contribute a backport, by all means, please contribute.
We are happy to help! 😄 Please post questions here:
Library | Description | Issues |
---|---|---|
KD | The KD language and library | Message Board |
Core | Ki.Types & utilities | Message Board |
Bugs and feature requests can be posted directly to Pivotal Tracker.
The Tag data structure is not thread-safe in any of the official implementations. In general, libraries should not make assumptions about how threads work in client apps. It is up to you to handle thread safety in a way most appropriate to your application. For Java, Kotlin and C#, if multiple threads have access to a tree of Tags it's a good idea to synchronize on the root Tag.
It is our experience that for most purposes KD doesn't need to be nested as deeply as XML (because of the value lists, anonymous tags, list and map literals, etc.) If you need deeply nested KD tags you can add a simple comment to the close bracket to avoid confusion.
tag1 {
tag2 {
tag3 {
}
} # tag2
} # tag1
The order of values and children is significant. Duplicates are allowed and the order in which they are listed is maintained in the KOM (KD Object Model). The order of attributes is not significant. Only one instance of an attribute key is allowed in a given tag.
Because squiggly brackets are used for tag bodies. KD uses square brackets for lists and maps (à la Swift) with key/value pairs separated by =
.
We are trying to keep KD simple by including only very commonly needed literal types. Others may be added in future versions based on demand.
KD for the JVM (Kotlin, Java, etc.) is in beta as of August, 2020. SDL, KD's predecessor, was released in 2005. It is in use on a number of large projects ranging from open source frameworks to systems developed for global investment banks. The project is actively maintained by multiple contributors.
If it is listed in the references section of the Language Guide, then yes, we have heard of it. Similar declarative languages like YAML met some but not all of our design goals. YAML code such as:
!!map {
? !!str "---"
: !!str "foo",
? !!str "...",
: !!str "bar"
}
...does not seem very natural in the modern language landscape. We feel KD's type inference from "natural" looking literals similar to those found in Swift, Java, Kotlin, Dart and C# are preferable. KD's maps (attributes) and lists look similar to analogous constructs in popular scripting languages.
Additionally, KD was designed to cleanly map to and from XML. This is not true for all the languages in our references list.
Great! You can start a discussion in the forum, post an issue or feature request to Pivotal Tracker, or submit a pull request to a repo.
Home · KD Docs · FAQ · Ki Types · KDS · KiTZ · Roadmap · Contribute · Download 🔸 KD-JVM Repo↗ · Core-JVM Repo↗
KD Docs
FAQ
Ki Types
KD Schema
KiTZ Time Zones
Roadmap
Contribute
Download
Code
KD-JVM Repo
Core-JVM Repo
Issues & Features
Pivotal Tracker ↗