3 ms·
> P.S. "Just use protobuf" is not a solution either. It's one solution, which makes it a solution. It also happens to be a good solution for 95%+ of data-inter
by stouset 9y ago
> P.S. "Just use protobuf" is not a solution either.
It's one solution, which makes it a solution. It also happens to be a good solution for 95%+ of data-interchange use-cases.
JSON is a genuinely terrible approach to interchange for most anything that you expect to grow to be nontrivial. Whatever your thought of static vs. dynamic typing for languages, schemaless interchange formats are absolute madness — an analogue to what people are rapidly learning about schemaless databases. "Schemaless" formats don't actually mean there isn't a schema. You have one, it's just informal and you lack any useful tools to manipulate it or make changes in the future.
What you gain in early development speed is lost many times overby not actually stopping to think about how your data will be modeled beforehand and it will be lost many times over again when you need to change your informal parsing logic (e.g., random hash accesses) that's spread across dozens of unrelated areas of your code and impossible to locate. As an added bonus, you often end up having to indefinitely support every buggy, half-baked version of this format going backward to the beginning of time.
- fpoling 9y agoJSON is terrible format for data storage. But for data exchange it is OK. The problem with schemaless storage is that as code evolve it is way to easy to forget to cover the needs of already stored but not presently accessed data. With communications this is much less a problem as serialization and parsing must evolve together with code.
- stouset 9y agoYou have this exact same issue with JSON for data interchange, unless there are exactly one producer and one consumer and you can deploy both simultaneously. If you have more than one producer, more than one consumer, or you don't have the control to update all participants simultaneously, you are setting yourself up for pain.