Markup Language

Protocol Buffers (protobuf)

I’ve heard of this before. Developed by people at Google.

Hemal introduced me to this again when talking about NVIDIA SDK.

Protobuf is a method for serializing structured data, similar to XML but smaller, faster, and simpler.

https://protobuf.dev/

I don’t get how protobufs are better.

JSON

{
  "name": "John Doe",
  "age": 30,
  "isStudent": false
}
  • Notice that the fields are strings (“name”, “age”, “isStudent”) are repeated every time this data structure is transmitted

JSON is verbose

JSON is a text-based format that includes all field names and string formatting with every data element, making it more readable but larger.

On the other hand, protobof

Proto definition

message Person {
  string name = 1;
  int32 age = 2;
  bool isStudent = 3;
}
  • It encodes data into a compact, efficient binary form rather than readable text. Protobuf uses predefined schemas and assigns a numeric tag to each field in a data structure, which are then used in the binary encoding

How is the schema used?

Look into gRPC.