4 ms·
I think that if we're going to have a full blown typed RPC system, we need to at least be able to represent generics/parametric polymorphism. As far as I know,
by calebh 8y ago
I think that if we're going to have a full blown typed RPC system, we need to at least be able to represent generics/parametric polymorphism. As far as I know, protobufs do not support this feature! Why are we settling for using a subpar interchange format when the alternative (polymorphic sum types) is so much better?
- superfrank 8y agoCan you give me an example where generics would be helpful? I'm not doubting you, my brain is just a little slow today and I'm struggling to think of a scenario where I feel I would NEED them for gRPC.
- wbl 8y agoIf I was to design a type system I would introduce sum and product as type constructors and some basic types and be done. To make this really work takes polymorphism so you can write list.
- deathanatos 8y agoOption<T>. Protobuf "supports" this particular case via other means: messages are always implicitly nullable, and the WKTs cover primitives, which don't count as messages. Map<K, V>: Protobuf has dedicated syntax for this case.
- calebh 8y agoGenerics and user defined types make it easier to represent more complicated data. Now everyone is just going to have to write custom encoders and decoders to get the data to a Protobuf compatible format, which is pretty much what we do right now with JSON. If you haven't used algebraic/sum types before, I highly recommend trying them out. Once you use them you won't want to go back.
- romed 8y agogRPC is not "typed" in any substantial way. You wan use any payload encoding you feel like suits your worldview. Protobufs happen to be a common choice.
- calebh 8y agoThe gRPC website mentions protocol buffers in the first sentence, and the Wikipedia page says that protocol buffers are used for gRPC. I consider a defacto standard to basically be equivalent to a standard, even if that's not "technically correct".
- ejona86 8y agoIt is true that gRPC tends to implicitly imply Protocol Buffers. It's the only format that is worked on directly by the gRPC team. However, C#/C++ Bond, C++ FlatBuffers, and Java Avro have some level of code generation support for gRPC. I'm not very familiar with Microsoft's Bond, but it appears to have generics for both the service and structs. disclaimer: I'm part of the gRPC team.