0
点赞
收藏
分享

微信扫一扫

Is Kotlin better than Java 8? [ & Kotlin Java Scala 文章集锦]

花海书香 2022-06-09 阅读 60

Java 8 is a mature language and with more developers and a community to support its use in android development with great results and productivity and more developers are used to Java 8.
Kotlin is safe, concise, interoperable, tool friendly and comes with data classes and other useful features below which java 8 does not offer.

“Kotlin has way, way more to offer than Java 8. Here is just a sampling (in no particular order)

Null-safety
Type inference
String interpolation
Data classes
Delegation
Smart casts
Conditionals as expressions
Sealed classes
The when expression
Extension functions
Co-routines in 1.1

... and I'm sure I've just scratched the surface”-​​What if the future of Kotlin when/if Java 8 becomes available on Android? • r/Kotlin​​

​​How will Java 8 impact Kotlin?​​“Comparison to Java Programming Language
Some Java issues addressed in Kotlin
Kotlin fixes a series of issues that Java suffers from
Null references are ​​controlled by the type system​​.
​​No raw types​​Arrays in Kotlin are ​​invariant​​Kotlin has proper ​​function types​​, as opposed to Java's SAM-conversions
​​Use-site variance​​
without wildcards

Kotlin does not have checked ​​exceptions​​

What Java has that Kotlin does not
​​​Checked exceptions​​​​Primitive types​​ that are not classes
​​Static members​​​​Non-private fields​​​​Wildcard-types​​

What Kotlin has that Java does not
​​​Lambda expressions​​​+​​Inline functions​​​ = performant custom control structures
​​​Extension functions​​​​Null-safety​​​​Smart casts​​​​String templates​​​​Properties​​​​Primary constructors​​​​First-class delegation​​​​Type inference for variable and property types​​​​Singletons​​​​Declaration-site variance & Type projections​​​​Range expressions​​​​Operator overloading​​​​Companion objects​​​​Data classes​​​​Separate interfaces for read-only and mutable collections​​​​Coroutines​​

​​Comparison to Java - Kotlin Programming Language​​

footnotes:
​​​Kotlin vs. Java: First Impressions Using Kotlin | ArcTouch​​​​Java vs. Kotlin: Should You Be Using Kotlin for Android Development?​​​​10 Features I Wish Java Would Steal From the Kotlin Language​​​​Java vs. Kotlin: First Impressions Using Kotlin for a Commercial Android Project - DZone Mobile​​​​Java 8 vs Kotlin​​​​Does Kotlin have better functional programming support than Java 8 streams and lambdas?​​​​Functional programming in Java 8, Kotlin and Scala​​​​Java vs. Kotlin: Android Programming Languages​​​​What are the advantages of Kotlin over Java?​​​​Kotlin vs Java: key differences between Android's officially-supported languages​​​​Kotlin Programming Language​​



举报

相关推荐

0 条评论