r/programming • u/ZealousidealStorm200 • 11d ago
What Go 1.27’s generic methods made possible for ORMs. Compile-checked columns with no generated code
https://skudra.net/blog/field-pointers-as-column-names
102
Upvotes
8
u/tef 11d ago
i feel it's worth noting that
u.Fieldwill also be a runtime error, but it's still a bit of a neat trick6
u/Lotaor_Wieth 11d ago
Does this still rely on reflection at runtime to map the rows back into structs, or is the whole path resolved at compile time now? Always wondered how much overhead generic methods actually save at runtime
4
u/txdv 11d ago
not everyone is happy about ORMs, but I guess you enable people and let them make decisions
1
u/standing_artisan 10d ago
Generics are not 100% free, they come with some amount of cost on the runtime of your program, yes not the magnitude of reflection but still not 100% free because of they hybrid approach on implementing generics. Based on this context. I still don't understand why would I ever use a gorm/ant or whatever and not write simple sql queryes and at MAX use a query builder where I need to create those dynamically.
-16
u/Beaverman 11d ago
This is LLM written.