3 ms·
Generics in java work via type erasure, so <T> is the same as interface{} by the time the code is running.
by mappu 10y ago
Generics in java work via type erasure, so <T> is the same as interface{} by the time the code is running.
- jhomedall 10y agoThat's not relevant to type safety, though. Haskell also has type erasure.
- magnushiie 10y agoAlthough I very much like C# where generics are not elided, I think most of the value comes from the productivity from static analysis, and therefore Java generics cature most of the value. Perf improvement opportunities are great though.
- hota_mazi 10y agoAbsolutely not, they are not the same. Without generics, the compiler can't make any guarantees on the soundness of your code. Go will accept code that's inherently broken and that Java will simply refuse to compile. I like to catch such errors as soon as possible. As for saying "they are the same once the code is running", well, duh, of course, but it's completely useless by then.