2 ms·
> Don't use binary formats when it isn't absolutely needed. JSON in particular isn't very good [0] but I'd also argue that text formats in general aren't great
by streetfighter64 8mo ago
> Don't use binary formats when it isn't absolutely needed.
JSON in particular isn't very good [0] but I'd also argue that text formats in general aren't great. Isn't it a lot better that an int32_t always takes exactly 4 bytes instead of anywhere between one and eleven bytes (-2147483648)?
[0] https://news.ycombinator.com/item?id=40555431 https://news.ycombinator.com/item?id=40555431
- coderatlarge 8mo agoone use-case is if you need to be able to stream the data.
- streetfighter64 8mo agoOne use-case of what? Whether a format is "streamable" is entirely orthogonal to whether it is text or binary. Streamability depends on other things such as if it has a header or checksum at the end, et cetera.
- zzo38computer 8mo agoI would agree that binary formats can be much better. Sometimes you can use fixed fields, but there are also structured formats such as DER (which is generally better than JSON in my opinion). JSON has many problems, including that it does not have a non-Unicode type (so you must use base64 encoding or hex encoding instead and that isn't very good), and other problems. Parsing it will also mean that you must handle escaping.