News for hackers. Stuff that matters.
Re:Java record pattern matching in JDK 19 by SemanticStrengh on Saturday May 14, 2022 @01:16PM (#31380118)
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.
Re:Java record pattern matching in JDK 19 by pron on Saturday May 14, 2022 @01:33PM (#31380307)
I 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.

Re:Java record pattern matching in JDK 19 by _old_dude_ on Saturday May 14, 2022 @02:10PM (#31380671)
The 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.

Re:Java record pattern matching in JDK 19 by kaba0 on Saturday May 14, 2022 @03:02PM (#31381211)
I think Kotlin went the easy way with extension methods. Scala’s solution is much more elegant with implicits (especially now with Scala 3).
Re:Java record pattern matching in JDK 19 by SemanticStrengh on Saturday May 14, 2022 @03:07PM (#31381263)
I'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...