Java uses type erasure which are very cheap in compile time but you cannot do things like
t = new T(); // T is a template parameter class
C++ uses reified generics which are heavy on compile time but allows the above.Java uses type erasure which are very cheap in compile time but you cannot do things like
t = new T(); // T is a template parameter class
C++ uses reified generics which are heavy on compile time but allows the above.
That's why they're called generic parameters, not template parameters; the code is generic over all possible parameters, not templated for every possible parameter.
Interesting I’d never picked up on this pedantic subtlety. I too thought reified meant what you could do at the call site not what you could do at runtime. Was my understanding wrong, or is Gemini hallucinating.
In any event, you have to use weird (I think “unsafe”) reflection tricks to get the type info back at runtime in Java. To the point where it makes you think it’s not supported by the language design but rather a clever accident that someone figured out how to abuse.