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.

  • Knusper@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    I’ve always wondered, if it’s also just less pain when you write plain/idiomatic Java.

    I write mostly functional Scala with lots of message passing and such, so data types often move through interfaces where their type may be lost and then we do lots of pattern matching, where missing runtime types come up on quite a regular basis.

    I’d say probably once a week, I have to write or come by an ugly portion of code where we had to manually pass around type information and do explicit casts to make it all fit together.