User loginNavigation |
Templates vs. GenericsBruce Eckel gives his take on C++ Templates vs. Java Generics, using the example of an apply() function that will apply any method to every object in a sequence: What I found in modifying this example and translating it to Java was surprising. As far as generics go, it does in fact support my thesis that erasure emasculates generics. What is surprising is that ... the Java code is small and elegant, and far less verbose than the C++ code,... Alas, generics had nothing to do with this succinctness – it was actually reflection and varargs that were responsible. And so the power of reflection continues to be one of the most interesting features of Java, even though its runtime uncertainty is at odds with the Java Generics goal of eliminating ClassCastExceptions.I figure the goal is for the compiler to proof the type correctness, but he's right in that RTTI is at odd with that goal. (Also of interest, is the link to the Java Generics FAQ). [Edit Note: The URLs should be working again] |
Browse archives
Active forum topics |
Recent comments
27 weeks 1 day ago
27 weeks 2 days ago
27 weeks 2 days ago
49 weeks 3 days ago
1 year 1 week ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 5 weeks ago
1 year 10 weeks ago
1 year 10 weeks ago