3 ms·
I'm sorry but this looks like an ad-hoc black or white thinking. Language design is made of tradeoffs e.g between features and complexity. However contrary to p
by The_rationalist 5y ago
I'm sorry but this looks like an ad-hoc black or white thinking.
Language design is made of tradeoffs e.g between features and complexity.
However contrary to popular opinion, I'd say that Kotlin actually has almost all Scala features and notably has important features that Scala does not (such as coroutines, reified generics, compile time safe tail recursive, etc)
The most unique Scala feature seems to be implicits. While I'm not convinced by their usefulness, the feature will be available in Kotlin in a few months:
https://github.com/Kotlin/KEEP/issues/259 https://github.com/Kotlin/KEEP/issues/259
I'd even argue it is more useful in Kotlin since the language is state of the art regarding it's ability toward making DSLs.
The major features that Scala 3 has that Kotlin does not that I can identify are:
1) Pattern matching ->
Kotlin is almost there, it has destructuring, a when control structure, and can express ADTs via sealed classes/interfaces.
The limitations are: name based destructuring is not implemented.
No destructuring in when blocks.
However since java will be getting extensive pattern matching support in jdk 19/20
I expect Kotlin to catch up there and I recognize pattern matching can be a very useful feature.
2) union types and intersection types.
While those are useful in a structurally typed language such as typescript, I don't see much usefulness for them in Kotlin. You can express union types via sealed classes somehow. The compiler plugin arrow meta brings union type support but I haven't tested it yet. As for intersection types it is on the roadmap.
The main usefulness of union types I can see are the union of exceptions in catch blocks, that BTW Java supports, surprisingly.
3) higher kinded types
I don't see much usefulness in higher kinder types
What else could their use be beyond abstracting over collections? Every Kotlin collection implement the interface Collection<T> which enable this use case.
Again, higher kinded types are supported by the arrow-meta compiler plugin.
To me the very few pain points of Kotlin have nothing to do with functional features but are:
1)
Inability to deflare a function parameter as mutable.
Inability to declare for loop element as mutable.
Which in fact are because of IMHO religious functional toxic beliefs about immutability everywhere.
2) no package private modifier (although java 9 modules are supported and they are working on the issue)
- kaba0 5y ago> I'd say that Kotlin actually has almost all Scala features and notably has important features that Scala does not (such as coroutines, reified generics, compile time safe tail recursive, etc) I really don’t see the point of coroutines, especially when a) project loom is on the horizon, b) higher kinded types make it quite trivial to implement as a library (answering your 3rd point) I’m not sure about reified generics, they are very seldom a problem and frankly, type erasure is most often just misunderstood. Also, with pattern matching overloading is used less often so it is even less of a win. Regarding compile time safe recursion, I’m pretty sure that Scala was actually the first bigger language implementing that (with an annotation), so it definitely has that. So don’t get me wrong, Kotlin is a great language with some nice features, I just don’t see it doing anything novel to be honest (and that’s not a bad thing! Non-research languages rarely do anything truly novel!). I just feel like Scala does all of those with less special cases (eg. extension functions can be done with implicits so you get one feature doing many things)