good disucssion, thanks.
Re 'generics vs c++ templates' -- agree they are
totally different things -- with the minor exception that the syntax looks nearly identical ( Type<Parameter> ) and that the words used to describe them are frequently abused and overloaded ('templates' , 'generics' , 'paramatized types' ) -- Doesnt do well for a clear understanding.
But when we start adding 'reified Generics' then the two start to have some overlap -- which may be not a good thing for understanding either ...
Which is why I was considering that "C++ Template" feature -- whatever you call it -- would NOT be a good candidate as an 'enhanced Generics feature' but rather something entirely different. Which
should help in terms of interop and compatibility issues -- by not attempting to make them the same -- it would not work very well 🙂
The 'c++ world' has encountered, and eventually addressed a good deal of the issues described -- like 'code size bloat', compile performance, API compatibility, affect on library code ... its been a long journey from the introduction of C++ Templates to where it is today -- which is still problematic in many ways -- but also very powerful -- including performance related issues -- being able to have full specialized type resolved implementation at compile time allows for a degree of optimization not easy (or possible often) at runtime -- boxing being a simple example.
With kotlin having added a 'toe-hold' into this area with inline classess -- the concepts are getting closer to each other ( c++ templates vs reified generics + inline classes) -- I suspect, given history and hindsight, that this will continue bit by bit over time as previously rejected concepts are re-evaluated and merged into kotlin. Its not very far from a reified inline function to an paramatized function template specialization. Then from there to complex inline classes, specialization.
IMHO the
BIG magic trick that C++11 pulled off was the implementation of "SFINAE' (
https://en.cppreference.com/w/cpp/language/sfinae) -- a concept worthy of either great esteem or an insane asylum especially built for the truly genius insane --