3 ms·
It's a tradeoff. Advanced generic programming as implemented in many other languages requires you to learn a completely new language. That new language is bette
by cyco130 2y ago
It's a tradeoff. Advanced generic programming as implemented in many other languages requires you to learn a completely new language. That new language is better suited for some use cases. Functions that take types and return types, on the other hand, can be more intuitive in other cases.
- littlestymaar 2y agoThe “new language ” is dramatically simpler than most programming language though because its expressing power is limited and as you say, you only need it for “advanced generics” which is only a small fraction of all generic code one writes. It's actually a DSL, tuned to the specific use-case it's doing.
- cyco130 2y agoIt’s usually not dramatically simpler though. Many of them (C++, TypeScript, Rust…) end up growing into esoteric, “accidentally Turing-complete” monstrosities that are much harder to reason about than simple if statements and loops.