Hacker News new | ask | show | jobs
by andrewmcwatters 3612 days ago
Could someone explain to me why you would use Protocol Buffers, Cap'n Proto, etc versus rolling your own type-length-value protocol besides API interop?

What if your team could write a smaller TLV protocol, and it was necessary to keep your codebase small? Would this not be wise? Are Protobufs and party not comparable to TLV protocols?

2 comments

In the vast majority of cases, you want your team to spend their time doing something other than reinventing protos, debugging the in-house implementation, maintaining the library, etc.

It's not clear to me anyway how doing it yourself would help keeping your codebase small vs using protos. In terms of code to maintain, doing it yourself is a net loss. In terms of binary size and method count, the proto libraries for Objective-C and Android are optimized like crazy.

Those are all reasons why I wanted to use protobufs to begin with. It sounded like it solved many issues for us.

But I'm thinking about scripting environments, where the data types used in protobufs don't exist in the host language. Simple things like this. I think in the implementations I've seen, they're just coerced or ignored. That's fine, imo.

But in terms of small codebases: a simple TLV protocol, where only limited data types are implemented, can be 1/10th of the size of any protobufs implementation.

My team has built out a high performance type-length-value system that doesn't require compiled schemas for game development, and we have a very small serialization lib that's smaller than any protobufs implementation for our target language.

I'd like to use protobufs to decrease the amount of modules we have to personally maintain, but I don't see the value in doing so for our particular situation.

I'm a bit confused: When you talk of size, are you talking of the compiled binary size of the runtime + generated code, or are you talking of lines of code?

If you're talking of binary size, I'm surprised that it'd be a problem given that you're using a scripting environment. Maybe you'd be willing to share more details?

If you're talking of lines of code, using someone else's library seems to me to always be better.

The efforts toward making the protocol robust might be helpful, depending on context. https://groups.google.com/d/topic/protobuf/DwyPEnvFJ-o/discu...