Live data from Hacker News

New better alterative to XML, JSON and YAML

xenondata.org

51–60 of 148 posts

Re: New better alterative to XML, JSON and YAML

#51
I have read this document, and I don't really like this alternative, much. However, one consideration should be that one format is not necessarily suitable for everything; there will be differences by data model and other stuff. Different formats have different advantages and disadvantages, both in general and for specific applications.

I had recently been working on something too, called TER. It is a pure ASCII file (although some implementations might support other character sets, mine doesn't, although non-ASCII characters can still be represented using escape sequences). It can be converted to DER (a program can also be written to convert the other direction (BER to TER), but this is not done yet).

It is ASN.1X which is a variant of ASN.1; a few types are removed (OID-IRI, and a few others) and some new types are added (BCD string, TRON string, PC string, key/value list, OBJECT IDENTIFIER RELATIVE TO, and a few others), and also a few types are deprecated (such as UTCTime), although they are intended to not conflict so that it is possible to implement both in the same program if you want to do. (ASN.1X also removes or restricts some other features of ASN.1, such as that optional fields and fields with a default value are not allowed if it would require to look ahead to determine the absence or presence of the field.)

Xenon has a type for references to other nodes. I had considered (before seeing the document about Xenon) adding such a type into ASN.1X, although I had not done so yet. (My idea is to use a relative format (I have the idea how this will be encoded in DER, although I am not sure about TER; for TER it might require multiple passes, and currently the implementation uses only a single pass), that if some structure is taken out and moved to another file, and it only references within that structure, the reference will remain intact, and it cannot interfere.)

TER also uses the same comment syntax than Xenon (although, so does PostScript, and probably others too).

Perhaps another thing to be noted is PostScript notation; a subset of the PostScript notation could be used for arrays and key/value lists and some such things like that (and is something I sometimes use).

Re: New better alterative to XML, JSON and YAML

#52

Sorry, as who have already designed yet another JSON alternative. Many things about this format are just wrong (as of the first edition): - (EDIT: Mistakenly read SHOULD as MUST, ignore this item please) The requirement for the mandatory BOM is unacceptable for most non-Windows users, as BOM is by definition invisible. - An arbitrary name is equally questionable, even XML doesn't do that. Do you accept tabs for examp…

> The requirement for the mandatory BOM is unacceptable for most non-Windows users

I think the requirement for Unicode is bad in general, whether it uses BOM or not.

> What on earth is "IEEE 64 bit double precision floating point numbers" in the context of textual format?

I assume it means that numbers are expected to be IEEE 64-bit floating point numbers represented in the decimal format.

> If you have to escape the base64 padding, maybe you should just drop the padding?

I agree.

> While technically a matter of choice, it uses a lot of unmatching angle brackets and that's just... ugly.

I agree with that too.

> No canonical representation.

I think that a binary format would be better as a canonical representation anyways. However, the lack of indicating the data type would seem to make it difficult to know how to convert it unless you already know the schema.

> Maybe you should review tons of other alternatives in this space

Just a few days ago, and still working on it today, I had been making something called TER. It might also be worth to look, and I wrote another comment relating to this.

Xenon does have a reference type to other nodes, which is something that other similar formats don't have, though.

Re: New better alterative to XML, JSON and YAML

#53

Sorry, as who have already designed yet another JSON alternative. Many things about this format are just wrong (as of the first edition): - (EDIT: Mistakenly read SHOULD as MUST, ignore this item please) The requirement for the mandatory BOM is unacceptable for most non-Windows users, as BOM is by definition invisible. - An arbitrary name is equally questionable, even XML doesn't do that. Do you accept tabs for examp…

There is no mandatory bom, it's recommended, not a must

Re: New better alterative to XML, JSON and YAML

#55

Sorry, as who have already designed yet another JSON alternative. Many things about this format are just wrong (as of the first edition): - (EDIT: Mistakenly read SHOULD as MUST, ignore this item please) The requirement for the mandatory BOM is unacceptable for most non-Windows users, as BOM is by definition invisible. - An arbitrary name is equally questionable, even XML doesn't do that. Do you accept tabs for examp…

> The requirement for the mandatory BOM is unacceptable for most non-Windows users I think the requirement for Unicode is bad in general, whether it uses BOM or not. > What on earth is "IEEE 64 bit double precision floating point numbers" in the context of textual format? I assume it means that numbers are expected to be IEEE 64-bit floating point numbers represented in the decimal format. > If you have to escape the…

> I think the requirement for Unicode is bad in general, whether it uses BOM or not.

While there exist legitimate complaints about Unicode, I believe there is no other feasible encoding than UTF-8 for textual formats now.

> I assume it means that numbers are expected to be IEEE 64-bit floating point numbers represented in the decimal format.

I too believe so (hence the next item), but that just doesn't make sense if you ponder. IEEE 754 doesn't define any textual format while it does have binary decimal formats. The correct wording should have been that numeric scalars follow a specific grammar to be interpreted as an IEEE 754 binary64 number in the data model.

> I think that a binary format would be better as a canonical representation anyways. However, the lack of indicating the data type would seem to make it difficult to know how to convert it unless you already know the schema.

That's fair. But we have already observed textual formats being... "abused" for the cryptographic purpose (e.g. JWT), so it's not too bad either to have a canonical representation or to explain why there is no canonical representation defined.

> Xenon does have a reference type to other nodes, which is something that other similar formats don't have, though.

There are several formats that do try to support native graph types, including YAML and Concise [1]. So that is hardly new. I think Concise actually tried very hard to make it fine! But it became quite more complex as a result.

[1] https://concise-encoding.org/

Re: New better alterative to XML, JSON and YAML

#56
post #53

Sorry, as who have already designed yet another JSON alternative. Many things about this format are just wrong (as of the first edition): - (EDIT: Mistakenly read SHOULD as MUST, ignore this item please) The requirement for the mandatory BOM is unacceptable for most non-Windows users, as BOM is by definition invisible. - An arbitrary name is equally questionable, even XML doesn't do that. Do you accept tabs for examp…

There is no mandatory bom, it's recommended, not a must

Thank you for noticing that, my mistake. Fixed by now.

Re: New better alterative to XML, JSON and YAML

#57
post #49

Sorry, as who have already designed yet another JSON alternative. Many things about this format are just wrong (as of the first edition): - (EDIT: Mistakenly read SHOULD as MUST, ignore this item please) The requirement for the mandatory BOM is unacceptable for most non-Windows users, as BOM is by definition invisible. - An arbitrary name is equally questionable, even XML doesn't do that. Do you accept tabs for examp…

Thanks for writing this up! Sounds like you really dig deeply in to this. Not entirely sure what you mean with canonical representation (I've heard this in the context of JSON-LD before, though). Can you explain what you mean here? Where do you see the problem with Graphs and Dos? A reference is just a pointer. You just have to be careful when doing recursive code. I actually like the idea to explicitly define how a…

Here the canonical representation refers to one single definite and unambiguous encoding for given data. This requirement is very common in cryptographic applications and also commonly demanded when the deterministic processing is desired. Technically the "canonical" and "deterministic" encoding can differ (e.g. ASN.1 CER vs. DER), but there is not much value to have two distinct encodings.

On graphs: as you've said recursive code has to be careful, but the recursion itself is not very frequent in normal applications and they are more susceptible to attacks if the recursion is built into the serialization format. XML billion laughs attack is a famous demonstration for this issue. It is still worthwhile to have parallel standards to specify how recursive structures should be encoded in the basic format, and possibly to tweak the basic format to better accommodate such standards, but I believe such needs can be met without making the basic format bigger.

Re: New better alterative to XML, JSON and YAML

#59
post #47

Earlier quoted context omitted.

Agreed that this is much better than the OP. That said, my general opinion is that a whitespace-only indentation should be avoided especially in the serialization format due to the inherent ambiguity of whitespace characters and resulting human mistakes. When I designed CSON [1] I strived to make it as readable as possible without the indentation for that reason. [1] https://github.com/lifthrasiir/cson

Nice – I like your verbatim syntax for multiline strings! I went with indentation because a very common use-case in a configuration file is commenting out lines. Even with CSON-like comma rules, you still need to balance your {} and []s. Indentation balances itself most* of the time.

Indentations are still desired for most human tasks indeed! But you can have indentations and groupings at once, one complementing each other. As you've noticed, CSON's verbatim syntax was intentionally designed so that it remains valid without any indentation but your instinct really wants to align those lines anyway. (A similar approach can be seen in Zig verbatim strings, which seem to be designed independently from CSON and make me much more confident about this choice.)

Re: New better alterative to XML, JSON and YAML

#60

Apple tried something similar https://pkl-lang.org/

Pkl belongs to a related but different category of "configuration" languages, while we are talking about a pure serialization format. A serialization format can be used as a configuration language if designed carefully, but they are distinct.
Post reply on HN