Hacker News new | ask | show | jobs
by wehadfun 3612 days ago
In C# why use Protocol Buffer over the XML or binary serializes?
3 comments

The C# binary serializer is not really comparable in terms of what it does. It's more like Python's Pickle library.

http://stackoverflow.com/questions/703073/what-are-the-defic...

C# binary serialization is only useful in certain circumstances. It doesn't work outside the .NET world and it even has compatibility problems within the .NET world—you can break deserialization by making certain changes to your code. From the Microsoft documentation:

> The state of a UTF-8 or UTF-7 encoded object is not preserved if the object is serialized and deserialized using different .NET Framework versions.

(From https://msdn.microsoft.com/en-us/library/72hyey7b(v=vs.110)....)

Also see https://msdn.microsoft.com/en-us/library/ms229752(v=vs.110)....

Performance and data size are much better with protobufs: http://stackoverflow.com/questions/549128/fast-and-compact-o.... Built-in serializers are only workable when both ends are on the same platform (i.e. .Net), and even then class versioning can be a problem.
Your message will be about 5% the size of the xml one, and it will be backwards compatible, unlike the built-in binary serializer.