3 ms·
there is nothing to be proud of about lacking extension methods. Kotlin has them and it allow to make amazing APIs that are much more ergonomic/reduce cognitive
by SemanticStrengh 4y ago
there is nothing to be proud of about lacking extension methods. Kotlin has them and it allow to make amazing APIs that are much more ergonomic/reduce cognitive overhead.
- pron 4y agoI personally think there's much to be proud of in lacking any feature, as long as you deliver what your users expect, especially if the number of users is very large. After all, the goal of a mainstream programming language is not to have as many features as possible, but as few as necessary, where "necessary" takes into account both the common software requirements of the era (which are also shaped by the hardware characteristics of the era) as well as the expectations and habits of the majority of programmers at that point in time. I can tell you that if Java's language team encounters some language feature that solves a particular problem, they'd rather spend spend several years thinking how to avoid adding that feature while still addressing the problem, than the six months needed to implement it. A good strategy for doing that is to wait, and try to think of ways to solve multiple problems with one feature (even if imperfectly) rather than solve multiple problems with multiple features.
- _old_dude_ 4y agoThe same feature does not entail the same tradeoff depending on the languages. For Kotlin, extensions methods are essential otherwise you can not extend existing Java types with Kotlin types. For C#, you need extension methods for LINQ because modifying the .Net runtime was not an option at that time. For Java, changing the VM is not an issue, instead of extension methods you add default methods which can be overridden by implementations. Same feature, different tradeoffs.
- kaba0 4y agoI think Kotlin went the easy way with extension methods. Scala’s solution is much more elegant with implicits (especially now with Scala 3).
- SemanticStrengh 4y agoI'd be very interested in a comparison between scala 3 using/given and Kotlin new context receivers https://github.com/Kotlin/KEEP/blob/master/proposals/context-receivers.md#detailed-design https://github.com/Kotlin/KEEP/blob/master/proposals/context...