News for hackers. Stuff that matters.
Re:Background: how we got the generics we have (2020) by paavohtl on Thursday April 01, 2021 @08:15AM (#26659487)
C# implements proper reified generics. Generic types parameterised with different types are actual types in C#, while in Java generics is basically just syntax sugar for avoiding type casts. Each element in a List<byte> in C# takes 8 bits, while in Java each element in a ArrayList<Byte> is actually just an Object and therefore is a pointer (64 bits) to a separate allocation.
Re:Background: how we got the generics we have (2020) by kaba0 on Thursday April 01, 2021 @11:41AM (#26661894)
But at the same time, reified types will create a separate object for each template type, making some optimizations happen only for a type that was used often. While in Java, ArrayList for example will benefit regardless of the concrete type.