jeudi 8 avril 2021

Why is .JSON recommended over static code for protobufjs?

For the protobufjs library, they recommend using .JSON over static code

https://github.com/protobufjs/protobuf.js/tree/master/cli#reflection-vs-static-code

For production environments it is recommended to bundle all your .proto files to a single .json file, which minimizes the number of network requests and avoids any parser overhead (hint: works with just the light library):

However, I don't understand why this is recommended:

  1. The number of network requests would be the same for JSON and compiled source code. In other words, both would just have one request if the user rendered the .proto files into one .js/.json file.
  2. To me, the 'minimal' library suggests a smaller size than 'light' library

And, as a smaller question, the "tradeoff" of no reflection for stati code seems wrong to me - I've thought of using reflection as a code smell. Am curious why this is listed as a trade off.





Aucun commentaire:

Enregistrer un commentaire