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

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: