Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To clarify, I tried to do something like this back in the 90's and it was _not_ worth the effort.

Using something like Google's Protocol Buffers or a similar system where you generate a standard serialization backend for all the plain old data types you want to send across the network is way less of a pain in the ass.

If you're concerned about the overhead, look at MsgPack or Cap'n Proto - plenty of ways to shave the yak out there without needing to roll your own.



You're talking about serialization, and I agree that using reflection for that is both an overkill and somewhat hacky (you still have to define the serialization format).

Reflection on the other hand is immensely useful if you want to, for example, automatically generate type-safe bindings for, say, Python or .NET or Java, from your C++ classes.


Wouldn't you prefer to generate type-safe bindings at compile-time?


Definitely. That's why I'm to hyped for compile-time reflection in C++: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/ (search for "reflection")


One of the authors of that paper, Matúš Chochlík, has been working on this for years. He has a pretty nice implementation that I've used successfully on a number of occasions, even though it requires a pre-compiler pass to generate the necessary data.

If I'm not mistaken, he has been working into getting the necessary data available from the compiler directly (which this paper would confirm).

Link to his existing library: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/

Absolutely great guy, as well. Really happy to see him still working on this, year over year.

Edit: DYAC.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: