News for hackers. Stuff that matters.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by kentonv on Saturday November 20, 2021 @07:30PM (#29293063)
> I wouldn't call what protobuf encodes type information.

Well... I would call it type information, just not complete.

> 32 bit values, 64 bit values and length prefixed values

In protobuf, most integer types are actually encoded as varints, i.e. variable-width integers, not fixed 32-bit or 64-bit. varint encoding encodes 7 bits per byte, and uses the extra bit to indicate whether there are more bytes. (It's not a very good encoding, as it is very branch-heavy. Don't use this in new protocols.)

> Can you even distinguish floats and ints without a schema in protobufs?

You can't distinguish between float vs. fixed32. But int32 would be varint-encoded, while floats are always fixed-width, so you could distinguish between those. (You can't distinguish between int32, uint32, and sint32, though -- and sint32 in particular won't coerce "in the obvious way" to the others.)

The really unfortunate thing is you can't distinguish between strings vs. nested messages (of the length-delimited variety). So if you don't specifically know that something is a nested message then it's not safe to try parsing it...

There are no comments on this comment yet.