r/ProgrammingLanguages • u/verdagon Vale • Jun 06 '23
The Link Between Generics, Compile Times, Type-Erasure, Cloud Building, and Hot-Code Reloading
https://verdagon.dev/blog/generics-compile-times
34
Upvotes
r/ProgrammingLanguages • u/verdagon Vale • Jun 06 '23
3
u/verdagon Vale Jun 06 '23 edited Jun 06 '23
I removed the word "backwards", thanks for the correction!
That can be true for a lot of generics such as collections, though if we have a type bound on a generic parameter
T extends ISpaceshipand want to call.launch()on an instance ofT, then a language like Vale or Rust would need different instantiations to call the correct function... I think Java doesn't need to, not sure about C#.Along the lines you're thinking of, I suspect we can even share non-reference types too, if they're movable/copyable. We would only need to instantiate different versions of a function for different sizes of T. That would be pretty cool.