4 ms·
Unless you have fixed width messages which you can directly map to a packed struct, json is waaayyy simpler to write and maintain.
by icholy 7y ago
Unless you have fixed width messages which you can directly map to a packed struct, json is waaayyy simpler to write and maintain.
- naikrovek 7y ago100% complete and total disagreement from me. 1) Write a JSON library from scratch. 2) Write a method to handle a binary format from scratch. 3) Compare them. I understand that you are likely relying on some JSON library or language feature, and I would argue that you will bear the weight of that all of that code the instant it has any problem, and that you bear the performance cost every time you use it. Maybe that library or language feature doesn't have any functionality bugs that you encounter; you will still pay for the loss in performance for as long as you use it. Maybe this is acceptable. For me, if I'm writing a tool that either delivers a result that a human relies on, or is a tool that a human uses, I consider it immoral to waste that human's time without a very good reason. I always try to avoid wasting my own time. Reasoning about code that reads and writes binary files is much easier for me than reasoning about an entire JSON library. Desktop, laptop, and tablet CPUs are not getting faster overall. In fact, they're getting slower as cores are added to the silicon dies. We've lived as developers for far too long under the performance gains provided by hardware advancement. Software has generally improved performance only when put on newer and faster hardware platforms. As a general rule, faster hardware platforms aren't a guarantee anymore. We may have more cores to run on, or more CPUs thrown at us to improve performance, yes. We can improve performance in other ways, with zero hardware cost. Avoiding JSON unless it is actually needed is one way we can reclaim performance from the debt of our previous decisions.
- icholy 7y ago100% complete and total disagreement from me. 1. Write your own C compiler. 2. Implement your binary encoding/decoding. I understand that you're relying on gcc or clang, and I would argue that you will bear the weight of that all of that code the instant it has any problem.