Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not Protobuff? #6

Open
nskazki opened this issue Jul 18, 2022 · 3 comments
Open

Why not Protobuff? #6

nskazki opened this issue Jul 18, 2022 · 3 comments

Comments

@nskazki
Copy link

nskazki commented Jul 18, 2022

If I'm to lose readability in favour of efficiency, I can as well use a community standard https://github.com/protobufjs/protobuf.js. In which cases JCOF would be preferable?

@mortie
Copy link
Owner

mortie commented Jul 18, 2022

I see protobuf and JCOF as serving different goals. Protobuf is a schema-based format with all the pros and cons that entails, and it complicates the build process by requiring a .proto compile step. JCOF is a self-describing schemaless format like JSON, and it's a normal library.

One use-case where JCOF is clearly preferable to protobuf is if you already have an application which uses JSON to serialize stuff; replacing JSON.parse with jcof.parse and JSON.stringify with jcof.stringify is all you need for a significant decrease in the size of your serialized objects.

Also, if you have an API or something which accepts JCOF, humans can write JCOF documents as plain text just like they can with JSON. Understanding the response is tricker, but that's also pretty doable at least with smaller objects. So it's much more human friendly than protobuf even though it's less human friendly than JSON.

Just being a plain-text format is also pretty advantageous in many cases, since it allows copy/pasting. Base64-encoded protobuf would have this advantage too, but most systems which use protobuf won't accept or output base64-encoded protobuf.

@nskazki
Copy link
Author

nskazki commented Jul 18, 2022

Thanks for the clear answer! Consider adding this to the readme.

@riking
Copy link

riking commented Jul 18, 2022

Flippant version: Protobuf is only "self describing" if you're okay with numbers for field names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants