5 ms·
I think the "we're not doing it because it adds complexity in the type system and runtime" was something most developpers have a very hard time understanding, s
by danieldk 7y ago
I think the "we're not doing it because it adds complexity in the type system and runtime" was something most developpers have a very hard time understanding, since generic programming exists in pratically every single PL created since C++.
Plus, history has taught us that retrofitting generics to existing languages with their ecosystems can be difficult and painful (see Java and to some extend C++).
- ryanianian 7y agoJava's generics are certainly awkward, and lots of code would look better if generics had been real from v1.0. I'm looking forward to Java's specialized generic impls (e.g. ArrayList<int>) that seem heavily inspired by the route C++ takes of compile-time class-instantiation. But out of curiosity what's difficult/painful about C++'s "retrofitted" generics (templates)? There's a lot to not like about templates, but as far as I know they've remained relatively unchanged and have always been just as difficult and painful (and powerful) as they are now. Are you referring to the decision to make SFINAE a de-facto way to constrain parameters?
- pjmlp 7y agoConcepts I guess, so much pain would have been saved if something like that existed in C++98.
- mook 7y ago> Plus, history has taught us that retrofitting generics to existing languages with their ecosystems can be difficult and painful (see Java and to some extend C++). I believe that C# also had retrofitted generics, but the reputation there doesn't seem nearly as bad. But I believe the generic containers there were intentionally not compatible with the original non-generic version.
- jen20 7y agoThe major difference is that the CLR is aware of generics rather them being a compiler trick as they are with the JVM. Don Syme (father of F#, who also worked on the implementation of generics in the CLR) did a talk explaining the history and how they almost shipped with erased generics like the JVM. On the other hand, it's been claimed that erased generics have made things easier for implementing other languages on the platform, so there are tradeoffs I guess. Having used both I would take the CLR implementation any day.
- pjmlp 7y agoSame here, but I still have high hopes for Valhalla.
- pjmlp 7y agoNot at all, Microsoft just decided not to delay .NET 1.0 release instead of having them fully implemented. https://mattwarren.org/2018/03/02/How-generics-were-added-to-.NET/ https://mattwarren.org/2018/03/02/How-generics-were-added-to...