3 ms·
> Uses ISO 8601, which has bad defaults (local timezone) and doesn't support real time zones (only offsets). ISO 8601 is also too big for what it does and non-f
by dragonwriter 6y ago
> Uses ISO 8601, which has bad defaults (local timezone) and doesn't support real time zones (only offsets). ISO 8601 is also too big for what it does and non-free, resulting in inconsistent implementations (and thus security problems).
Ion doesn’t use ISO8601; it has its own timestamp specification, which is free, and much smaller than ISO8601; its effectively a subprofile of a profile specified in a W3C note of ISO8601, but that relationship is mostly of historical interest, since it isn’t specified an a (sub)profile, but independently. It also has a UTC default.
> Lists must be prefixed with their length, so you must know the length before you start encoding.
True.
> Converting a list from the text format to binary format would require loading the entire list into memory first.
You’d have to process the entire list before starting to write it to the final format, because the format is optimized for read efficiency not write efficiency. But you don’t need to read the whole list into memory; you can use a state machine with a very small window to count items in this lost, write the total, and then start copying items from text to to binary, or you could just counts as you arr processing items to a scratch file, then write the length and copy the scratch file contents.
Length prefixing variable length data values is kind of important though; I’d consider it a major strike against a binary format if it didn’t do that. (Though Ion does have the problem that its length records are also variable length.)
> Only supports "struct" encoding, so you can't have real maps (for example using integers or dates as keys).
You can, since it supports type annotations and has formats that can with annotations communicate that. (List would probably be the normal choice.)
> Doesn't support arbitrarily long scalar values.
Yes, it does, which is why the length fields for most values, including most scalars, in the binary format use VarUInt.
> Doesn't support NaN or infinity.
Yes, it does. (It doesn’t, in text format or data model, distinguish different NaNs, but it supports NaN, +Inf, and -Inf.)
> Integer, date, and decimal float encodings are inefficient.
Ion has arbitary precision exact decimals, not decimal floating point, so, no, it doesn’t have an inefficient encoding for decimal floating point.
- kstenerud 6y ago> its effectively a subprofile of a profile specified in a W3C note of ISO8601, but that relationship is mostly of historical interest, since it isn’t specified an a (sub)profile, but independently. It also has a UTC default. Oh good, that's an improvement. Unfortunately, nobody thought to include real time zones :/ > You’d have to process the entire list before starting to write it to the final format, because the format is optimized for read efficiency not write efficiency. Knowing how many objects are in the list won't help efficiency because you still don't know how big each element is. So you still need to walk through the list regardless. With that in mind, there's no advantage to a size field over an end marker, but there are disadvantages. > Length prefixing variable length data values is kind of important though; I’d consider it a major strike against a binary format if it didn’t do that. (Though Ion does have the problem that its length records are also variable length.) I did add typed arrays to CE to support efficient storage of monosized data types such as bool and int and float. Those have chunked size prefixes. > You can, since it supports type annotations and has formats that can with annotations communicate that. (List would probably be the normal choice.) I'm just not a fan of requiring users to massage data structures and annotations to get basic type behaviors. Technically you can get everything you need from XML too, but the costs... >> Doesn't support arbitrarily long scalar values. > Yes, it does, which is why the length fields for most values, including most scalars, in the binary format use VarUInt. Ah cool, didn't know that, thanks! >> Doesn't support NaN or infinity. > Yes, it does. (It doesn’t, in text format or data model, distinguish different NaNs, but it supports NaN, +Inf, and -Inf.) As I understood it, the text format didn't have "nan" or "inf" literals... unless I missed it somewhere?