News for hackers. Stuff that matters.
Re:New better alterative to XML, JSON and YAML by lifthrasiir on Monday November 04, 2024 @05:55AM (#42040409)
> Which?

Oh, I just realized that I carelessly put "English-speaking" there. (AFAIK the exact reversal does exist in English, but is much rarer and not entirely domestic.) But that doesn't really justify the use of comma in numbers.

> .net for example has round trip encoding to achieve this.

That was never guaranteed to my knowledge, and there also seems an apparent difference in .NET Framework and .NET Core/Runtime versions according to some searches. Many enough standardized languages have no strong requirement as well (for example, see [1] for ECMAScript), so this should be clearly specified to be truly portable.

[1] https://tc39.es/ecma262/multipage/abstract-operations.html#s...

> As linked in the document, we refer to ʀꜰᴄ 4648 for Base64 using the simplest version [...].

You are free to rephrase any variant of base64 standard into simple statements. (Ideally the standard itself should be also cited, though.) I was asking why that particular variant was used.

> Layering graphs on top of the encoding in a separate standard is not practical. As stated serialization requires a graph structure.

The separateness here is not binary. The Unicode standard (ISO/IEC 10646) for example has multiple standard annexes [2] that are synchronized with the core standard but published and developed separately. For all practical purposes they form a single unified standard, but you can (and almost likely should) ignore some irrelevant annexes. I'm arguing for a similar structure to be clear, do you think that's also a no-go?

[2] https://www.unicode.org/reports/

> I have done that.

The only explicit thing in your data model is the following definition:

    // Read as: "document" is either "object", "array" or "scalar".
    document = object | array | scalar
    // Read as: "object" is a distinct type "Object" with "name" and zero or more "field"s. (And so on)
    object = Object(name, field*)
    array = Array(name, item*)
    scalar = Scalar(name, value)
This is not what's implied by following sections. To begin with, you have no explicit definition of `item` or `field`. Yes, it is kinda obvious that both should be `document` and also can be somehow inferred that `scalar` in the `item` place should be a nameless object, but not only such relations are not explicit but now we have another class of objects not mentioned in the first place! The exact nature of `value` is also very unclear.

In my understanding, your data model is more like this:

    document = object | array | scalar

    // `...?` for zero or one copy of the preceding data.
    optional-name = Name(name)?
    optional-ref-id = RefId(ref-id)?
    optional-type = Type(type)?

    name = string             // Can't be empty
    ref-id = string           // Globally unique
    type = string             // Interpretation up to clients

    object = Object(optional-name, optional-ref-id, optional-type, field*)
    field = ObjectField(name, optional-ref-id, optional-type, field*)
          | scalar

    array = Array(optional-name, item*)
    item = object
         | ScalarItem(optional-ref-id, field*)  // Implicitly converted to object
         | ReferenceItem(reference-id)

    scalar = Scalar(name, value)
           | Reference(name, ref-id)
    value = string    // Additional interpretation rules may exist after parsing
For example, the following document:

    <Person>
        <Name=Bonnie>
        <Spouse#jack-smith>
            <Name=Jack>
        <$>
        <Doctor=@jack-smith>
    <$>
...is thought to parsed into the following underlying data:

    Object(Name("Person"),
        Scalar(Name("Name"), "Bonnie"),
        ObjectField(Name("Spouse"), RefId("jack-smith"),
            Scalar(Name("Name"), "Jack")
        ),
        Reference(Name("Doctor"), "jack-smith")
    )
This abstraction clearly demonstrates many important things coming up in implementations. For example, every `field` has to provide `name` because all possible branches (`ObjectField`, `Scalar` or `Reference`) have one---at least in my understanding. I shouldn't be figuring out such data model myself to be honest; it's your job to provide one.
Re:New better alterative to XML, JSON and YAML by GeneThomas on Monday November 04, 2024 @08:57PM (#42047976)
>But that doesn't really justify the use of comma in numbers.

Readability.

>I was asking why that particular variant [of Base64] was used.

I repeat, we are using the ʀꜰᴄ 4648 variant.

> [separate standards documents] do you think that's also a no-go? Yes.

Data model here:

document := named-entity

named-entity := named-object | named-array | named-scalar

named-object := NamedObject(name, object)

named-array := NamedArray(name, array)

named-scalar := NamedScalar(name, scalar)

object := Object(id?, type?, field*)

array := Array(id?, type?, item*)

scalar := Scalar(id?, type?, value)

field := named-entity

item := object | array | scalar

name := CHAR+

id := CHAR+

type := CHAR+

value := CHAR*

Re:New better alterative to XML, JSON and YAML by lifthrasiir on Tuesday November 05, 2024 @02:52AM (#42049492)
> Readability.

Okay, I see you demand a very explicit question: why did you use comma instead of other characters for grouping?

> [separate standards documents] do you think that's also a no-go? Yes.

I like to hear why then, given this approach seems to be very successful for Unicode and many others.

> Data model here:

Thank you for the grammar. The document will massively benefit from such explicit description, I completely missed an unnamed scalar for example (because it has no syntax at all). The grammer doesn't have to be reproduced at all, for example the following is my attempt to rephrase it in prose:

There are three kinds of entities in Xenon: objects, arrays and scalars. All entities may optionally have a name, a type, an ID or any combination of them. Objects can contain named entities or fields, where field names should be distinct within the same object. Arrays can contain either named or unnamed entities. Scalars can contain zero or more characters. Names and types are non-empty free-form strings and no meanings are assigned for them, but this document gives a guideline for common types to ensure the interoperability. IDs should be distinct within the same document, but otherwise they are only used to encode a graph structure and have no other meaning. Objects and arrays can contain a reference which can stand in for any entity with given ID; references in an object needs its own name which can differ from the referent.

Please consider a similar clarification early in the document.

Re:New better alterative to XML, JSON and YAML by GeneThomas on Tuesday November 05, 2024 @03:21AM (#42049639)
> why did you use comma instead of other characters for grouping?

Because English is the global lingua franca

> I like to hear why then

Unlike Unicode xᴇɴᴏɴ must be defined in one grammar. Having special names, like $type, and hoping no language uses them is fragile.

Re:New better alterative to XML, JSON and YAML by lifthrasiir on Wednesday November 06, 2024 @09:44PM (#42072800)
> Because English is the global lingua franca

But English is not the largest language in terms of the number of speakers. I speak Korean for example and three-digit grouping is unnatural in Korean, which uses myriads instead. I guess Xenon is designed to be not comfortable for the vast majority of people including me then?

> Having special names, like $type, and hoping no language uses them is fragile.

I was not proposing special names after all. Xenon clearly has a much better extension point, namely the type string. You can have just one reserved character, which is very unlikely to appear in verbatim, and use it for the extension. And it is even unclear whether JSON's use of `$` for such special names was fragile after all, given that such complaint seems uncommon. (I complained about that in the past, but I mean others seemed to be cool.)

In addition, I don't think you have mapped enough languages to conclude so anyway. For example, can you list all popular enough languages that allow `$` in identifiers? While whether to allow `$` or not requires a single example, maybe you have missed other identifiers in other languages! (Angle brackets are also common in stringified types, after all.) So I expected you to have at least looked at them for your conclusion.

Re:New better alterative to XML, JSON and YAML by GeneThomas on Thursday November 07, 2024 @08:55PM (#42083347)
> I guess Xenon is designed to be not comfortable for the vast majority of people including me then?

You seem fairly comfortable with the rest of English. Korean numbers do not seem to scale well.

> allow `$` or not requires a single example

Java allows $ in identifiers.

Re:New better alterative to XML, JSON and YAML by GeneThomas on Monday November 18, 2024 @11:03PM (#42180013)
I have silenced all criticism.

The new Xenon Design Rationale shows how Xenon is the best data description language.

https://xenondata.org/xenon-design-rationale.html

Comment at https://news.ycombinator.com/item?id=42178359