logoalt Hacker News

barishnamazovtoday at 2:05 AM4 repliesview on HN

You shouldn't be using JSON for things that'd have performance implications.


Replies

creationixtoday at 3:38 AM

As with most things in engineering, it depends. There are real logistical costs to using binary formats. This format is almost compact as a binary format while still retaining all the nice qualities of being an ASCII friendly encoding (you can embed it anywhere strings are allowed, including copy-paste workflows)

Think of it as a hybrid between JSON, SQLite, and generic compression. This format really excels for use cases where large read-only build artifacts are queried by worker nodes like an embedded database.

show 1 reply
hrmtst93837today at 10:18 AM

That rule sounds clean until the DB dump, API trace, or langauge boundary lands in your lap. Binary formats are fine for tight inner loops, but once the data leaks into logs, tooling, support, or a second codebase, the bytes you saved tend to come back as time lost decoding some bespoke mess.

squirrelloustoday at 4:45 AM

I agree in principle. However JSON tooling has also got so good that other formats, when not optimized and held correctly, can be worse than JSON. For example IME stock protocol buffers can be worse than a well optimized JSON library (as much as it pains me to say this).

show 1 reply
Spivaktoday at 2:19 AM

Can you imagine if a service as chatty and performance sensitive as Discord used JSON for their entire API surface?