4 ms·
Dude, read the fucking docs before passing judgment. http://confluence.jetbrains.net/display/Kotlin/Classes+and+Inheritance http://confluence.jetbrains.net/dis
by bad_user 15y ago
Dude, read the fucking docs before passing judgment.
http://confluence.jetbrains.net/display/Kotlin/Classes+and+Inheritance http://confluence.jetbrains.net/display/Kotlin/Classes+and+I...
Basically the language has no notion of interfaces; preferring instead multiple inheritance. Then the diamond problem is taken care of by making mandatory the overriding of conflicts. See the provided example:
http://confluence.jetbrains.net/display/Kotlin/Classes+and+Inheritance#ClassesandInheritance-Diamondinheritance http://confluence.jetbrains.net/display/Kotlin/Classes+and+I...
Then, it also has syntactic sugar for the Delegation pattern:
http://confluence.jetbrains.net/display/Kotlin/Classes+and+Inheritance#ClassesandInheritance-Delegation http://confluence.jetbrains.net/display/Kotlin/Classes+and+I...
One cool thing about Scala's implicit conversions is that they eliminate many use-cases which would make you use traits. Kotlin has a similar mechanism, but kind of different (taken from C#); extension methods:
http://confluence.jetbrains.net/display/Kotlin/Extension+functions http://confluence.jetbrains.net/display/Kotlin/Extension+fun...
The classic trait I'm thinking about when thinking about traits is the Enumerable module in Ruby:
http://www.ruby-doc.org/core/classes/Enumerable.html http://www.ruby-doc.org/core/classes/Enumerable.html
This is a classic example of where a trait is useful for providing common implementation for collections that only have to implement "each". The cool thing about extension methods is that you can implement all those methods in the Enumerable module above, without dealing with multiple inheritance or traits.
The difference between implicit conversions and extension methods is that implicit conversions are more flexible, but extension methods are easier to reason about and (being statically resolved at compile-time) don't suffer from performance penalties.
I'm not saying that what Kotlin does is better than Scala, but it does seem simpler. Personally I can't wait to play with it.