4 ms·
Why do all these serialization frameworks like protobufs, flatbuffers, capnproto, etc. have bespoke schema languages? Why not just use JSON-based schema so that
by umvi 3y ago
Why do all these serialization frameworks like protobufs, flatbuffers, capnproto, etc. have bespoke schema languages? Why not just use JSON-based schema so that you don't need custom parsers for it? It would definitely make metaprogramming easier as well.
- kentonv 3y agoBecause JSON-based schemas are excessively verbose making them painful to read and write, to the point where really nobody wants to do so. Consider: struct Person { name @0 :Text; age @1 :UInt16; } vs.: "declarations": [ { "name": "Person", "kind": "struct", "fields": [ { "name": "name", "type": "text", "ordinal": 0 }, { "name": "age", "type": "uint16", "ordinal": 1 } ] } ]
- zamalek 3y agoAlso JSON schemas can represent the exact same type in multiple ways, meaning some form of normalization is required prior.
- thayne 3y agoAvro uses json for its schema language.
- never_inline 3y agoBut also has a schema language, and a avro.reflect which can construct schema from java class. Avro schema in Json is very unreadable in my experience. Another bad thing is something like ["int", "null"] gets formatted over 2 lines by standard JSON formatters, making it even harder to read.
- thayne 3y ago> But also has a schema language, Really? I admittedly don't know a whole lot about avro, but everything I've been able to find about avro schemas uses json. Edit: I found it: https://avro.apache.org/docs/1.11.1/idl-language/ https://avro.apache.org/docs/1.11.1/idl-language/
- never_inline 3y agoYeah JSON is usually the way it's written. IIRC the IDL even lacks some features of JSON. But the fact it exists means at least some people find JSON verbose.
- eklitzke 3y agoWhy not just use JSON for everything? Why isn't /etc/passwd JSON?