logoalt Hacker News

SuperV1234yesterday at 2:47 PM1 replyview on HN

I think this is a very bad take -- once you write it by hand you have to manually keep it in sync with the actual struct and ensure you made no mistakes. Reflection guarantees 1-1 future-proof mapping with the actual C++ struct, avoids boilerplate, and ensures that the serialization logic is correct.


Replies

bluGillyesterday at 3:55 PM

The protocol is important though, not the internal structure. When you only have exactly one version of a program talking to the same version of itself you don't care. However when you are mixing versions or worse programming language (and thus can't mix structs which are implementation details of your language) the protocol is what matters.

That is if you are worried about doing this by hand reflection is not the answer, something like protobuf where your data structures are generated is the answer.

show 1 reply