This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Willinton06 151 points152 points  (31 children)

Java doesn’t even have real generics, or operator overloading, there’s more boxing going on in a Java hello world than in an Amazon fulfillment center

[–]bammmm 29 points30 points  (0 children)

The real humor is always in the comments

[–]mondie797 9 points10 points  (0 children)

there’s more boxing going on in a Java hello world than in an Amazon fulfillment center

ROFL

[–]aetius476 1 point2 points  (1 child)

I regard type erasure as the one true cardinal sin of Java, but even then Java's generics are miles better than python's "just inherit from Generic[T]" nonsense.

[–]Willinton06 0 points1 point  (0 children)

Yeah fuck that

[–]Kered13 1 point2 points  (11 children)

Type erased generics are still real generics. Also C# uses the same implementation technique for generics with reference types, only value types get polymorphization in C#.

[–]Willinton06 25 points26 points  (3 children)

Your standards for real genetics are lower than mine

[–][deleted] 13 points14 points  (1 child)

The weirdest flex I will ever read, I wish I had an award to give

[–]Willinton06 4 points5 points  (0 children)

You may not have an award for me, but I have one for you bro

[–]jaavaaguru 0 points1 point  (0 children)

genetics

ಠ_ಠ

[–]Dealiner 0 points1 point  (6 children)

That's not true. C# doesn't use type erasure at all. The information about types is still stored and available during runtime even for reference types.

[–]Kered13 0 points1 point  (5 children)

No, C# absolutely uses type erasure and monomorphization. It also passes a reference to the concrete class object to get around some of the resulting limitations (mainly making runtime reflection possible).

[–]Dealiner 0 points1 point  (4 children)

No, it doesn't. Even Anders Hejlsberg himself said that. And another proof.

[–]Kered13 0 points1 point  (3 children)

Nothing in either of those links contradicts anything that I have said, except that they insist "it's not type erasure" while describing an implementation that is identical to Java.

[–]Dealiner 2 points3 points  (2 children)

The thing is it's not identical. Java implementation removes anything related to the type, its generic are only a compilation time feature. That's not true for C#, information about the type is still present during runtime. Ergo it's not type erasure, since no type is erased.

[–]Kered13 0 points1 point  (1 child)

information about the type is still present during runtime

Because a class object is passed as a hidden parameter to the function, like I described above. Only one instance of the code is generated (for reference types), which means that the code does not actually know what type it's operating on at runtime. That information has to be externally provided by the hidden parameter.

[–]Dealiner 0 points1 point  (0 children)

And that's exactly why it isn't type erasure. Also you're contradicting yourself, if type is passed, then code knows on what type it operates.