近日,JetBrains 官博發文慶祝 Kotlin 十歲了,并制作紀念網站和視頻來慶賀和記錄這一關鍵時刻,
2011 年 7 月 19 日,在 JVM 的編程語言峰會上,JetBrains 正式官宣 Kotlin 編程語言,一種新的 JVM 靜態型別編程語言, Kotlin 已經從 Java 替代品發展成一個完整的生態系統,允許為不同需求的專案撰寫代碼,包括服務器端、移動、Web 前端、資料科學,甚至多平臺專案,
官方制作的慶賀網站分為三大部分,過去、現在、未來,基于時間軸分享 Kotlin 在過去取得了一些里程碑成就與事件,
回顧過去
下面我們一起乘坐時光機,看看Kotlin 在過去都有哪些重要更新與高光時刻,
-
第一篇 Hello World 面世文章
-
第一個語法型別
Function 型別 和 Function literals
//Functions
fun f(p: Int) : String { return p.toString() }
//Function types
fun (p: Int) : String, fun (Int) : String
//Function literals
{ (p: Int) : String => p.toString()} {(p : Int) => p.toString() }
{p => p.toString()}
高階函式
fun filter<T>(
c: Iterable<T>,
f: fun (T) : Boolean
): Iterable<T>
val list = list("a", "ab", "abc", "") filter(list, { s => s.length() < 3 })
- 語法大改變,包括 命名空間替換成關鍵詞,使用“細箭”(->)取代 “肥箭”(=>),函式型別變得更具可讀性,
// before:
fun max(col: Collection<Int>, compare: fun(Int, Int): Int): Int
// after:
fun max(col: Collection<Int>, compare: (Int, Int) -> Int): Int
- Kotlin 的第一個Web 演示

- 宣布正式開源
- 正式在Android上運行
package com.example
import android.app.Activity
import android.os.Bundle
class HelloKotlin() : Activity() {
protected override fun onCreate(savedInstanceState: Bundle?) {
super<Activity>.onCreate(savedInstanceState)
setContentView(R.layout.main)
}
}
- 使用Kotlin全面開發Web應用
- 首個資料塊的SAM轉換
- 添加新的語言特征:委托屬性、可呼叫參考、靜態常量和靜態欄位
- 發布Gradle插件
- Kotlinlang.org成立
- 添加新特性改善JavaScript互操作,添加dynamic關鍵字來支持動態宣告,內嵌 JS 代碼, IntelliJ IDEA 增加對 Kotlin 依賴注入支持,
jquery.getJSON(KotlinCommitsURL) { commits ->
val commitsTable = jquery("#kotlin-commits")
commits.forEach { commit ->
commitsTable.append("""
${commit.sha.substring(0, 6)}
${commit.commit.message}
""")
}
}
- 改善開發體驗,支持多個建構式、伴隨物件、密封類、lateinit 屬性
class MyView : View {
constructor(context: Context, attrs: AttributeSet, defStyle: Int): super(context, attrs, defStyle) {
// ...
}
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) {}
}
- 在 Kotlin 1.0 發布之前對語言進行重新修正,比如洗掉一些棄用專案,擺脫在測驗版期間發現的一些遺留位元組碼特性,移動一些 stdlib 代碼,以便那里的包具有更多結構,
- Kotlin 1.0 正式發布
- 將 Kotlin 用于 Gradle 構建腳本的第一個里程碑
- 協程首先出現
fun main(args: Array<String>) {
val future = async<String> {
(1..5).map {
await (startLongAsyncOperation(it)) // suspend while the long method is running
}.joinToString(" ")
}
println(future.get())
}
- 第一個 Kotlin 之夜在舊金山舉行

- Kotlin 成 Android 官方支持語言
- Kotlin 用戶組支持計劃啟動,Kotlin Nights 成為社區驅動的系列活動
- Kotlin 1.1 發布
- Kotlin 首本書籍面世

- Kotlin/Native 的第一個技術預覽上線
- 第一屆 KotlinConf 在舊金山舉行

- Kotlin 1.2 發布
- Kotlin 框架 Ktor 1.0 發布
- 行內類可以在不創建實際包裝物件的情況下包裝某種型別的值
inline class Name(internal val value: String)
-
Kotlin 1.3 發布
-
Kotlin 可以嵌入到文章等相關素材中
<script src="https://unpkg.com/kotlin-playground@1"
data-selector="code"></script>
-
KotlinConf 2018 在阿姆斯特丹舉行
-
Kotlin成Android首選編程語言
-
為 Kotlin 類實作了 SAM 轉換
fun interface Action {
fun run()
}
fun runAction(a: Action) = a.run()
fun main() {
runAction {
println("Hello, KotlinConf!")
}
}
- 首個 Kotlin Heroes 競賽在 Codeforces 上舉行
- KotlinConf 2019 在哥本哈根舉行
- Kotlin Multiplatform Mobile 移至 Alpha
- Kotlin 1.4 發布
- Andrey Breslav 下臺,Roman Elizarov 成為 Kotlin 的新專案負責人

- Kotlinx.serialization 1.0 發布
- 宣布了 Kotlin 和 Kotlin 插件的新發布節奏,Kotlin 1.X 每六個月發布一次
- 《Atomic Kotlin 》一書面世
以上的 Kotlin 從出生到 2020年的一些變化,
現在
當前 Kotlin 的最新穩定版本為 1.5.21,具體特征及教程,感興趣的同學可以前往:https://kotlinlang.org/docs/home.html 查看,

未來計劃
除了回顧過去和介紹當下,Kotlin 專案負責人 Roman Elizarov 還介紹了 Kotlin 的一些未來計劃,主要分為以下幾大塊:
- 打造Kotlin為多平臺的編程語言
- 結構資料
- 代碼安全,不變性
- 新編譯器
- 元編程
- 更多靜態型別
最后,我們祝 Kotlin 10 歲生日快樂,作為開發者,你對 Kotlin? 有哪些祝福跟期許呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/292382.html
標籤:其他
