Skip to content(if available)orjump to list(if available)

PHP compile time generics: yay or nay?

tobinfekkes

Can someone smarter than me explain what they mean by "reified generics", "erased generics", and a use case for when to use one over the other?

gloryjulio

Example, Java is using erased generics. Once the code is compiled, the generics information is no longer in the bytecode. List<String> becomes List<>. This is called type erasure.

C# is using reified generics where this information is preserved. List<String> is still List<String> after compilation

Gibbon1

I'm not smarter than you but.

I believe the terms reified generics and erased generics is the type sweaty donkey ball terminology you get for professional CS academics.

Sticking my neck out further.

Reified generics means the type is available at run time. In C# you can write if(obj.GetType() == typeof(typename))

Erased generics the type information is not available at run time. That's the way Java does it and it kinda sucks.

p1necone

Academics invent short names for common (in their field) concepts not because they're 'sweaty' but because if the thing you're going to mention in every second paragraph in a good chunk of the communication you do with other people working on the same topic requires a full sentence to explain you're going to A. get really annoyed at having to type it out all the time and B. probably explain it slightly differently every time and confuse people.

Academic jargon isn't invented to be elitist, it's invented to improve communication.

(of course there's a good chance you understand this already, and you're just making a dumb joke, but I figured I'd explain this anyway for the benefit of everyone reading)

null

[deleted]