The state of Kotlin 2019

Kotlin History

  • Kotlin v1.0 was released on 15 February 2016
  • At Google I/O 2017, Google announced first-class support for Kotlin on Android.
  • Kotlin v1.2 was released on 28 November 2017. Sharing code between JVM and Javascript platforms feature was newly added to this release.
  • Kotlin v1.3 was released on 29 October 2018, bringing coroutines for asynchronous programming.
  • On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers.

What the meaning of “Kotlin”?

The name comes from Kotlin Island, near St. Petersburg. Andrey Breslav mentioned that the team decided to name it after an island just like Java was named after the Indonesian island of Java[8] (though the programming language Java was perhaps named after the coffee).

Why Kotlin?

图片[1]-The state of Kotlin 2019 - 拾光赋-拾光赋
Kotlin is also very easy to learn. It has very short learning curve.

Stack overflow survey 2019 – loved

图片[2]-The state of Kotlin 2019 - 拾光赋-拾光赋
Source: https://insights.stackoverflow.com/survey/2019

This survey was made before Google announced that the Kotlin as preferred language.

Stack overflow survey 2019 – popular

2019, first time Kotlin get’s into popular languages
图片[3]-The state of Kotlin 2019 - 拾光赋-拾光赋
Source: https://insights.stackoverflow.com/survey/2019

GitHub trends – 2018

图片[4]-The state of Kotlin 2019 - 拾光赋-拾光赋
Source: https://octoverse.github.com/projects.html

What Kotlin is used for

图片[5]-The state of Kotlin 2019 - 拾光赋-拾光赋
Source: https://pusher.com/state-of-kotlin

Basic Syntax

Data class

Extensions

图片[6]-The state of Kotlin 2019 - 拾光赋-拾光赋
This is what allows you to call toString() in Kotlin without checking for null: the check happens inside the extension function.

Sequence vs. Iterable

图片[7]-The state of Kotlin 2019 - 拾光赋-拾光赋
With Sequence we inspect 23 nodes vs. 21 nodes with itarable. Obviously, We can save more as the nodes count increases.

Coroutines

Kotlin’s support for coroutines helps build server-side applications that scale to massive numbers of clients with modest hardware requirements.
图片[8]-The state of Kotlin 2019 - 拾光赋-拾光赋
Output:

Recursion

In Java long recursion is not recommended because of the cost of the stack space.
In Kotlin we have tail optimization:

Performance

Summary

Kotlin look like a better alternative to Java. It run on top the JVM just like java since it compiles to byte code.
Kotlin is not just for android developers. I use it at my backend server.
It allows me to write cleaner code and to focus at business logic instead of the java technical implementation details and boilerplate code.
Refactoring old java project became much easier (with extensions, class delegation and more) and you can start writing new code in Kotlin while keeping older parts of your system in Java.

More details

https://kotlinlang.org/docs/reference/
https://play.kotlinlang.org/koans/

原文链接:The state of Kotlin 2019

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容