Kotlin 2.0.0 के प्रमुख बदलाव
(kotlinlang.org)- Kotlin K2 कंपाइलर अब आधिकारिक स्थिर संस्करण बन गया है। पुराने कंपाइलर की तुलना में बेहतर performance, नई language features के विकास में अधिक गति, और multiplatform projects के लिए बेहतर संरचना जैसे फायदे हैं
- local variables और अधिक व्यापक scope, logical
oroperations का उपयोग करने वाले type checks, inline functions, function-type properties, exception handling, और increment/decrement operators आदि में smart cast बेहतर हुआ है - multiplatform projects में common और platform source compilation अब सख्ती से अलग किए जाते हैं।
expect/actualdeclarations में अब visibility level अलग-अलग हो सकते हैं - Kotlin/Wasm में Binaryen का उपयोग करके optimization का default support, named export support,
@JsExportfunctions में unsigned primitive types का support, JS exception catch support आदि में सुधार हुआ है - Kotlin/JS में
es2015compilation target जोड़ा गया है,suspendfunctions को ES generator के रूप में compile किया जाता है,mainfunction में arguments पास किए जा सकते हैं, file-level compilation, collection interop improvements, औरjs-plain-objectsplugin जैसे सुधार हुए हैं - Kotlin Multiplatform में Gradle DSL से compiler options configure करना, Compose compiler plugin integration, Kotlin data folder में बदलाव, और जरूरत पड़ने पर Kotlin/Native compiler डाउनलोड करना जैसी चीज़ों में सुधार हुआ है
- standard library में enum class
valuesgeneric function replacement,AutoCloseableinterface, और common extension functions आदि अब stable हो गए हैं
1 टिप्पणियां
यह एक सरल (और बेहद चरम) compiler performance benchmark है।
https://github.com/ganadist/kotlin_build_performance
हर project में 200 class हैं, और हर class में 2000 field शामिल हैं
java : 2 सेकंड
kotlin 1.9.24 : 1 मिनट 20 सेकंड
kotlin 2.0.0 : 1 मिनट 1 सेकंड
इसे Macbook Pro M1 Max पर जांचा गया।
ऊपर दिया गया project थोड़ा चरम case है, और आम तौर पर लगता है कि kotlin 1.9 की तुलना में 2.0 की compile speed लगभग 2 गुना है।