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

Compile time generic programming is not a replacement for runtime reflection. A great example of this is if you want to use dynamically generated protocol buffers.

A great usecase for this is if you want to store each row in a database as a proto message. Instantiate a descriptor based on the table schema and go.



> Compile time generic programming is not a replacement for runtime reflection.

Why not?

> A great example of this is if you want to use dynamically generated protocol buffers.

When would you want to do that? If your data isn't statically typed, isn't it more appropriate to use a type designed for dynamic shapes (e.g. a list or hashmap)?

> A great usecase for this is if you want to store each row in a database as a proto message.

Wouldn't a reasonable approach to this be to turn each row into a list (of variants) and serialize that?


> Compile time generic programming is not a replacement for runtime reflection.

Yes, it is, especially since the former can be used to implement the latter.




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

Search: