A great read for folks wondering why Java uses type erasure instead of “reified” generics. For the unaware, that means that a List<Integer> is a List<Object> at runtime. I had always wondered about it and why they didn’t take the alternative route. For context, C# does have reified types so the actual type parameter is available at runtime.

I personally love reading in depth discussions about counter intuitive engineering decisions like this.

  • TomM
    link
    fedilink
    arrow-up
    2
    ·
    2 years ago

    Ah, that makes sense!

    I guess I haven’t really run into many examples like this. The times I’ve run into code where the former developers clearly struggled with handling types correctly has nearly always been their own fault (bad interface, bad organization of data, etc)

    • JackbyDevOPM
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Yeah, agreed. My first project as a junior dev was on Java 6 using something written before Java 5 that they sort of slapped generics all over for no apparent reason. So many warnings lol.