3 ms·
Kotlin didn't change, the only difference is `trait` keyword replaced with `interface` keyword. But I'm not really getting this article. Inheritance is key prin
by vbezhenar 10y ago
Kotlin didn't change, the only difference is `trait` keyword replaced with `interface` keyword. But I'm not really getting this article. Inheritance is key principle of Object-Oriented Programming, throwing it away would be very stupid move. It could be abused, but everything could. Kotlin solves this in pragmatic way: if you need inheritance, you must declare it explicitly. If you want delegation, Kotlin got you covered with awesome delegate syntax. The choice is up to you.
Also remember that good compatibility with Java is a big priority for Kotlin, so inheritance works very similar to Java and compiles to the same obvious JVM structures.
- dhfhduk 10y agoThanks. This is helpful. I guess part of what I'm wondering is how much Kotlin interfaces compare to Scala traits in the sense explained here: https://en.wikibooks.org/wiki/Scala/Traits https://en.wikibooks.org/wiki/Scala/Traits Or, in another example, how does use of Rust impl map onto Kotlin? http://www.jonathanturner.org/2016/02/down-the-rabbit-hole-with-traits.html http://www.jonathanturner.org/2016/02/down-the-rabbit-hole-w... I really don't mean this as a criticism of Kotlin, I'm just trying to map this all out. Kotlin seems nice and like something I could use, but I'm sure it has its boundaries also.
- brianon99 10y agoNo , inhertiance is not a key part of oop. Look at Rust and Go. https://lwn.net/Articles/548560/ https://lwn.net/Articles/548560/