2 replies
by paragd Accepted solution
by vermanshul Accepted solution
Starting from the C++:-
In it compiler checks what all different versions of a Template calls can be required. and then generates a copy each for each version. Hence emitting all the possible required code in the binary files.
In Java:-
Java Generics are a step ahead, they internally map each instance as object and hide the type safety from user. But, internally they are used as Object classes.
In C#:-
C# has the latest and till date best implementation of Generics (as far as i know). It would not do anything while compiling, rather than placing some meta tags. Each time it is called for a specific data type, a version of that Generic class/ method is generated and chached (to be used later). So it does not emit all the code before hand .. as in C++; and it also does not convert it to OBJECT as in Java
This discussion is closed to new replies.
Trending Software posts
Sort by Trending