SDLang – Simple Declarative Language
sdlang.org
sdlang.org
; Maps are denoted as key-value pairs inside curly brackets:
{:title "Hello, World"}
; Vectors are denoted by square brackets:
[:bookmarks 12 15 188 1234]
; Or you can use a map with a keyword that maps to a vector:
{:bookmarks [12 15 188 1234]}
; Maps are collections of key-value pairs:
{:author "Peter Parker"
:email "peter@example.org"
:active? true}
; Data structures are heterogeneous and nest:
[:contents
[:section "First section"
[:p "This is the first paragraph"]
[:p "This is the second paragraph"]]]
; ^ Hiccup actually renders these to HTML.
; Everything is an expression, so strings just work:
"This text is the value of an anonymous node!"
; A matrix is just a vector:
[1 0 0
0 1 0
0 0 1]
; Or you could partition it into rows:
[[1 0 0]
[0 1 0]
[0 0 1]]
https://github.com/edn-format/ednThis is true, but due to its origin I think we have a weak agreement over the JSON data model: it is a JavaScript value unless ambiguous. We do expect dotted number literals represent IEEE 754 binary64 numbers (importantly, this is pretty much the only case that excess precision do not alter the value), undotted number literals of the range (-2^31, 2^31) (exclusive) represent 32-bit integers, string literals with no lone surrogates and no unescaped U+2028/U+2029 represent Unicode strings, objects with no duplicate keys represent a partial mapping from strings to values.
It is very common to avoid a valid but ambiguous and/or problematic subset of JSON, e.g. most encoders avoid unescaped U+2028/U+2029. Given that I think it is more useful to have a profile of JSON with the defined semantics than to have a substantially different format. Preferably that should be included to the JSON standard (RFC 8259, ECMA-404, ISO/IEC 21778 or whatever) itself.
> See also https://preserves.gitlab.io/preserves/why-not-json.html
Note that this link was also submitted to HN by its own: https://news.ycombinator.com/item?id=24946268
So this:
p {
"mixed"
img href="test.png"
"content"
}
is worse than: <p>mixed<img href="test" />content</p>
... at least as markup, since having to wrap all text in quotes is tedious.The other language I know of that provides "natural" mixed content is scribble [1], but I think the only implementation that I know of is the racket one, since it is so tied to racket semantics.
If you take mixed content away from XML, then you may as well use one of the myriad of existing IDL languages, no?
1: https://docs.racket-lang.org/scribble/getting-started.html
server foo {
port = 80
root = '/'
section bar {
...
}
}
could become: {name: "foo", port: 80, root: "/", "bar": { ... } }
And you can use if statements and loops to generate repetitive structures! Rather than using textual templating.(The syntax is all there, but the evaluation is incomplete -- contact me if you want to help, and influence the API/language design)
-----
The shell is a logical place for configuration, because shells start processes that need configuration. Configs are often passed in as environment variables or flags.
The syntax can support:
title "Hello World" # like SDLang
in addition to title = "Hello World"
although I'm still wondering if we should enforce one or the other for consistency. The latter is more flexible in Oil because you have arbitrary expressions on the RHS.Any concept of namespaces? I read the page, saw none. I have this mapping of XML to EDN that I want to apply, maybe port the stock XMPP transport. (I’ve a Patreon if this sounds good, same handle).
// Namespaces are supported
renderer:options "invisible"
physics:options "nocollide"- JSON is massively underspecified. Its specification(s) alone can't produce multiple conformant implementations, as famously demonstrated by [1].
- JSON by its own is annoying to write because it doesn't support trailling commas nor comments. Most uses of JSON as configuration format (e.g. Visual Studio Code) would actually use (unspecified) extensions to make it more palatable.
- JSON has an undefined data model, generally thought to be a version of JavaScript values but not exactly. Have you ever dealt with 64-bit integers?
- JSON's (probable) data model lacks many important types, most notably a set, a true mapping with non-string keys and a byte array. You are likely to suffer if you need them. Disjunctive (or sum) types like `Ok(value) | Err(error)` are also painful to handle.
- JSON doesn't have a defined canonicalization algorithm, almost surely required by cryptographic protocols (and we live in the world where they are a thing). There are tons of mutually incompatible proposals.
- Being a subset of JavaScript, JSON is hard to parse efficiently and doesn't allow random access. Note that this is not unique to JSON and shared by many other formats including binary ones, but JSON is so ubiquitous that it is often used for inappropriate cases. It is not as impossible as simdjson [2] demonstrates (and multiple redundant syntaxes of JSON are actually beneficial for simdjson), but it's better to use random-accessible formats if you need performance.
- Being a subset of JavaScript, JSON is huge. Even much so if you embed it to other JSON (doubles quotes). Again, it's a problem mainly because of inappropriate uses. Pretty much any binary format will beat JSON in this regard.