$30 off During Our Annual Pro Sale. View Details »

Kotlin 2.0을 통해 알아보는 코틀린의 미래

Kotlin 2.0을 통해 알아보는 코틀린의 미래

라인 테크 토크에서 공유한 "코틀린 2.0을 통해 알아보는 코틀린의 미래" 발표 자료입니다.

Leonardo YongUk Kim

May 24, 2023
Tweet

More Decks by Leonardo YongUk Kim

Other Decks in Programming

Transcript

  1. 2 Contents 01 02 03 04 05 Kotlin 2.0 ߂

    ୶о੸ੋ ঱য੄ ૓ച Kotlin Multiplatform Compose for iOS Compose for Desktop Compose for Web
  2. 6 ೐ۿ౟ূ٘৬ ߔূ٘о ޖ঺ੋоਃ? ೐ۿ౟ ূ٘ ౵ࢲ৬ दݭ౮ গօۄ੉੷۽ ҳࢿ.

    ࣗझ௏٘ܳ ੍য ҳޙ ౟ܻܳ ٜ݅Ҋ ੄޷ ੿ࠁܳ ୶оೣ. ߔূ٘ ઺р ௏٘ ࢤࢿ & ୭੸ചӝ৬ ݠन ௏٘ ࢤࢿ ୭੸ ച۽ ա־য૗. ୭੸ചܳ ೞҊ ӝ҅য ௏٘ա ఋѶ ௏٘ܳ ࢤࢿ. 
 ௏ౣܽ੄ ҃਋ীח ੗߄ Bytecodeա LLVM੄ Bitcodeо ఋѶ. ௏ౣܽ ௏ౣܽ੄ ҃਋ী (1.3ө૑) ઺р ௏٘ ࢤࢿ & ୭੸ ചӝо হ঻਺. 
 ബਯࠁ׮ח ௏ౣܽ ঱য੄ ߊ੹੉ ؊ ઺ਃ೮਺. (ӝࣿࠗ଻) https://twitter.com/kotlin
  3. 7 ߔূ٘ী IR੄ بੑ IR ߔূ٘ীࢲ ҕਬೞח ઺р ࣻળ੄ ঱য

    IR generator & optimizer IRਸ ٜ݅Ҋ ୭੸ച ೞח ౵౟. 
 ௏ౣܽ ֎੉౭࠳ܳ ٜ݅ݴ ࢜܂ѱ ୶о. ੉ റ JVM(1.5)җ JS(1.6)ਸ IRਸ ॳب۾ ੤ ੘ࢿ. 
 
 ҕా੸ੋ ୭੸ചܳ ೡ ࣻ ੓׮. (Ӓ੹ө૑ ח ߔূ٘݃׮ ߹ب۽ ੘ࢿ.) 
 
 ੄بೞ૑ח ঋও૑݅ ࢜ ߔূ٘੄ ࢿמ੉ ೱ࢚! https://twitter.com/kotlin
  4. թ਷ Ѫ਷ ೐ۿ౟ূ٘ ۨѢद PSI (Program Structure Interface) PSI Program

    Structure Interface ௏ౣܽ ௏٘ܳ ౵यೠ Ѿҗ ౟ܻ. IntelliJীࢲ ݢ੷ ॳ؍ ҳઑܳ ௏ౣܽ ஹ౵ੌ۞ب ରਊ. ࣗझ ௏٘৬ Ѣ੄ ؀਽غח ױࣽೠ ഋక.
  5. PSI + BindingContextо ޙઁо ੓աਃ? ୭੸ച ೐ۿ౟ূ٘ ࣻળীࢲ PSIীࢲ ୭੸ചܳ

    ೞח Ѫ੉ औ૑ ঋ਺. ޙݓ੉ ߹ب੄ BIndingContextী ੓ח Ѫب ୭੸ചী જ૑ ޅೣ. நए ޷झ BindingContextо Ѣ؀ೠ Map੉যࢲ நए ബਯী જ૑ ޅೣ.
  6. ೐ۿ౟ূ٘ ৵ FIR੉ فѐо ੓աਃ? ౵ࢲ 3BX'*3࠽؊ "OBMZ[F ୓ழ ౵झ౟ܻ

    '*3 '*3 ૓ױ Lowering ױࣽച(simplify)ۄҊ ࢸݺ. ٣गѢ݂(Desugraing)੉ۄҊب ಴അ. ࠺ҳઑച (Desctructure)ܳ োࣘػ ؀ੑਵ۽ ߸҃. for ١ਸ whileਵ۽ ߸҃. ো࢑੗(+, +=, in, …)١ਸ ݺद੸ੋ ഐ୹۽ ߸ഋ. ӝఋ ೐ۿ౟ূ٘ ࣻળীࢲ੄ ୭੸ചب ࣻ೯.
  7. 18 FIR ӝ߈੄ ೐ۿ౟ূ౟੄ ੢੼ ஹ౵ੌ۞ ࢿמ FIR ӝ߈ਵ۽ ݅ٚ

    ೐ۿ౟ূ٘ח PSI + BindingContext ӝ߈੄ ೐ۿ౟ূ٘ ࠁ׮ ഻न ࡅܴ. IDE IDEب ೐ۿ౟ূ٘ܳ ҕਬ. ੋభܻઁ੉ীࢲ ੄޷ܳ ౵ঈೞҊ ௏٘ ೞ੉ۄ੉౴, ࠙ࢳೞח ࣘبо ࡈۄ૗. Kotlin IDE ೒۞Ӓੋ ੤੘ࢿ઺.
  8. 19 о੢ ݆੉ ਃ୒߉਷ ӝמ Static Extensions ੋझఢझо ইפ؊ۄب ഛ੢

    ೣࣻܳ ٜ݅ ࣻ ੓਺. Collection Literals listOf, mapOf, setOf о ইצ ܻఠۡ۽ ஸ۩࣌. Name-based Destructuring ࠺ҳઑച(ҳઑ࠙೧)ܳ ਤ஖ ӝ߈੉ ইפۄ ੉ܴ ӝ߈ਵ۽. Explicit Fields э਷ ஶࣆ੄ private, public ೐۽ಌ౭ܳ ٜ݅૑ ঋইب ؽ. Context Receivers ݯߡ ഛ੢ ೣࣻ ੉৻ী Contextܳ ૑੿ೡ ߑߨ੄ ୶о.
  9. 30 ੉ܴ ӝ߈ ࠺ҳઑച (Name-Based Restructuring) https://youtrack.jetbrains.com/issue/KT-19627 EBUBDMBTT1FSTPO  WBM

    fi STU/BNF4USJOH  WBMMBTU/BNF4USJOH  WBM fi STU/BNF MBTU/BNF QFSTPO
  10. 31 ੉ܴ ӝ߈ ࠺ҳઑച (Name-Based Restructuring) https://youtrack.jetbrains.com/issue/KT-19627 EBUBDMBTT1FSTPO  WBM

    fi STU/BNF4USJOH  WBMMBTU/BNF4USJOH  WBM MBTU/BNF  fi STU/BNF QFSTPO
  11. 33 ஶఖझ౟ ࣻन੗ (Context Receivers) https://youtrack.jetbrains.com/issue/KT-10468 fun process( context: ServiceContext,

    request: ServiceRequest ) { val data = request.loadData(context) } context(ServiceContext) fun processRequest(request: ServiceRequest)
  12. 36 ݺद੸ ೙٘ (Explicit Fields) https://youtrack.jetbrains.com/issue/KT-14663 private val _applicationState =

    MutableStateFlow(State()) val applicationState: StateFlow<State> get() = _applicationState
  13. 37 ݺद੸ ೙٘ (Explicit Fields) https://youtrack.jetbrains.com/issue/KT-14663 private val _applicationState =

    MutableStateFlow(State()) val applicationState: StateFlow<State> get() = _applicationState val applicationState: StateFlow<State> fi eld = MutableStateFlow(State())
  14. 40 K2 ೐ۿ౟ূ٘ীࢲח ೒۞Ӓੋਸ ੸ਊೞӝ एਕࢲ ೧Ѿ val df =

    DataFrame.readCSV("KotlinSO.csv") val kmp = df. fi lter { tags?.contains("multiplatform") ?: false } kmp.add("years") { creationData.year } .groupBy { year } .count()
  15. 46 Kotlin Multiplatform Mobileਸ ਤ೧ ೙ਃೠ Ѫ Android Studio ݣ౭೒ۖಬ

    গ೒ܻா੉࣌ਸ ٜ݅Ҋ दޛۨ੉ఠա ೞ٘ਝযܳ प೯.
  16. 47 Kotlin Multiplatform Mobileਸ ਤ೧ ೙ਃೠ Ѫ Xcode Xcodeח ߔӒۄ਍٘ীࢲ

    ࣻ೯ ؽ. Kotlin/Nativeо ੄ઓೞח ߡ੹ਸ ࢸ஖೧ঠ ೣ.
  17. 48 Kotlin Multiplatform Mobileਸ ਤ೧ ೙ਃೠ Ѫ Kotlin Multiplatform Mobile

    উ٘۽੉٘ झౚ٣য়ীࢲ Kotlin Multiplatform Mobile ೒۞Ӓੋ ࢸ஖.
  18. 49 Kotlin Multiplatform Mobileਸ ਤ೧ ೙ਃೠ Ѫ JDK Android Studioী

    ੄೧ ࢸ஖. Kotlin Plugin Android Studioী ࢸ஖. সؘ੉౟ܳ ೧ࢲ ߡ੹ਸ ୭नച ೧ঠ.
  19. 51

  20. 55 জ ֎੐ ӝࠄਵ۽ androidApp, iosApp, shared۽ জ ֎੐੉ ੿೧૗.

    iOS framework distribution਷ Regular۽ Cocoapods -_-ਸ ࢶఖೡ ࣻ ੓਺.
  21. 60

  22. 61 ߡ੹ ୊ܻח যڌѱ ೮ਸөਃ? expect৬ actual shared/src/ commonMain iOS৬

    Androidীࢲ ݽف ࢎਊೡ ੋఠಕ੉झܳ expect ఃਕ٘۽ ݅ٞ.
  23. 64 KMM for iOSীࢲ ݅աѱ غח ࢚ടٜ ObjC അ੤ Kotlin਷

    ObjC݅ ૑ਗ೧ࢲ ઁցܼ ௿ېझ݅ ૑ਗೞҊ ੋఠಕ੉झܳ ૑ਗೞ૑ ޅೣ. Abstract classܳ ؀न ࢎਊ೧ঠ ೣ. 
 @HinddenFromObjC, @ObjcName ఃਕ٘ܳ ੸ӓ੸ਵ۽ ഝਊೞ੗. @ObjcName(swiftName=“_”) _ח ౠࣻೠ ఃਕ٘. plane.fuel(volume: .Gallos(gallos: 12.5)) ؀न plane.fuel(.Gallons(12.5)) 
 ੢ӝ੸ਵ۽ח ௏౟ܽ੉ Swiftܳ ߄۽ ఋѱ౴ೡ Ѫ੐. Swiftܳ ObjeCܳ ઁ৻ೞҊ ߄ੋ٘ೡ ࣻ হ঻ӝী ߊ ࢤೠ ޙઁ. SourceKitten৬ э਷ بҳٜ۽ ઺р ௏٘ܳ ࢤࢿೞ੗. ۄੋ ؘݫী஠੉ ѻ਷ য۰਑ Suspend suspendח ௒ߔ(completion handler)੉ غҊ ௒ߔ਷ Swiftীࢲ async۽ ഐ୹ оמೞ૑݅ ஂࣗо ࠛ оמೣ. Flowب ੜ ૑ਗغ૑ ঋ਺. 
 KMP-NativeCoroutines ۄ੉࠳۞ܻܳ ഝਊ೧ঠ ೣ. https://github.com/rickclephas/KMP-NativeCoroutines 
 ௏ౣܽ ৘৻о झਤ೐౟ ೩ٜ۞ ੹׳ غ૑ ঋਸ ࣻ ੓য @Throws ఃਕ٘۽ Errorܳ ૑੿೧ঠ ೣ.
  24. 65 KMM for iOSীࢲ ݅աѱ غח ࢚ടٜ CocoaPods ই૒ ҕध੸ਵ۽

    SPM(Swift Package Manager)ܳ ૑ਗೞ૑ ঋ਺. Gradle API ࣻળীࢲ ੿ܻػ ੉റ ী ૑ਗೠ׮Ҋ ೣ. (঱ઁ?) CocoaPodsח ੄ઓࢿਸ ࣗझ۽ оઉ৬ э੉ ࠽٘ী ࢎਊೞӝী ݒ਋ ࠺ബਯ੸. TouchLab੄ ۄ੉࠳۞ܻ KMMBridgeܳ ࢎਊ೤द׮. https://github.com/touchlab/KMMBridge 
 
 SPMਸ ؀਽ೞӝ ਤ೧ࢲח Git ܻನ૑షܻ৬ झక౮ ౵ੌ ੷੢ࣗо ೙ਃೞ׮. (AWS?) Frozen Global Objectח ӝࠄਵ۽ frozen. ੽Ӕೡ ࣻ ੓૑݅ ߸҃ೡ ࣻ হ਺. @ThreadLocalਸ ࠢ੉ݶ freeze ഐ୹ উೣ. Atomicೠ ੗ܐҳઑ੄ ࢎਊ੉ ೙ਃೡ ࣻ ੓׮. 
 freeze() ഛ੢ ೣࣻܳ ੉ਊ೧ ؘ੉ఠܳ ঴ܾ ࣻ ੓Ҋ ಽ ࣻח হ਺. Global ೐۽ಌ౭ח ݫੋझۨ٘ীࢲ݅ ࠅ ࣻ ੓਺.
  25. 66 KMM for iOSীࢲ ݅աѱ غח ࢚ടٜ Memory Management झఖ

    ౟ۨ੉झ ٣ߡӦ য۵Ҋ, ݫݽܻ ݒפ૑ݢ౟о ই૒ উ੿੸੉૑ח ঋ਺. 
 https://youtrack.jetbrains.com/issue/KT-55512 ଵҊ Kotlin Multiplatform Mobileਸ ഝਊೠ ؘ݃ী஢ ٘ۄ੉ߡজ ѐߊ ੉ঠӝ Kotlin/Multiplatform for iOS developers : state & future by Salomon Brys
  26. 69 Compose for iOSܳ ਤ೧ ೙ਃೠ Ѫ Android Studio Android

    জҗ iOS জܳ प೯ೡ ࣻ ੓ח ѐߊ ജ҃. Xcode Xcodeח ߔӒۄ਍٘ীࢲ ࣻ೯ ؽ. Kotlin/Nativeо ੄ઓೞח ߡ੹ਸ ࢸ஖೧ঠ ೣ. Kotlin Multiplatform Mobile উ٘۽੉٘ झౚ٣য়ীࢲ Kotlin Multiplatform Mobile ೒۞Ӓੋ ࢸ஖. CocoaPods Compose for iOSب SPM(SwiftPackageManager)ܳ ૑ਗೞ૑ ঋ਺.
  27. 78 Compose for Desktop੄ ౠ૚ Cross- Platform ݣ౭೒ۖಬ੉ ইצ ௼۽झ೒ۖಬਵ۽

    ࠙ܨ. 
 JVM੉ ఋѶ੉Ҋ JVM ؋ী ৈ۞ ೒ۖಬীࢲ بח Ѫਸ ௼۽झ೒ۖಬਵ۽ ࢸݺ. SKIKO SKIA੄ ௏ౣܽ ߄ੋ٬ SKIKOী ੄೧ ۪؊݂. https://github.com/JetBrains/skiko SKIA੄ ಪ౟ ۪؊݂੉ ਍৔୓ઁ ݃׮ ׳ۄ झ௼ܽ ࢫ పझ౟ܳ ೞ૑ ݈੗. Compose Multiplatform IDE support ੋభܻઁ੉ ই੉٣যա উ٘۽੉٘ झౚ٣য়ী ࢸ஖. https://plugins.jetbrains.com/plugin/16541-compose-multiplatform-ide-support IntelliJ IDEA ੋభܻઁ੉ ই੉٣য 2020.3 ੉࢚ীࢲ ࢎਊоמ.
  28. 79 Compose for Desktop੄ ౠ૚ ଵҊ৔࢚ You can do desktop

    too! By Victor Kropp https://www.youtube.com/watch?v=Mgf_9kxM1BA JDK 15 JDK11ਵ۽ ೐۽ં౟ ࢤࢿ оמ. ֎੉౭࠳ ߓನ ಁః૚ਸ ਤ೧ࢲח 15 ੉࢚.
  29. 81

  30. 82

  31. 84 Compose for Web੄ ౠ૚ WebAssembly JavaScriptܳ ॳ૑ ঋҊ WebAssembly۽

    प೯. Kotlin/WASM੉ ఋѶ. Compose HTML HTMLਸ ࢤࢿೞח Kotlin/JS੄ ۄ੉࠳۞ܻب ੓਺. Compose for Webҗ ޖҙ. Compose Multiplatform IDE support ੋభܻઁ੉ ই੉٣যա উ٘۽੉٘ झౚ٣য়ী ࢸ஖. https://plugins.jetbrains.com/plugin/16541-compose-multiplatform-ide-support IntelliJ IDEA ੋభܻઁ੉ ই੉٣য 2020.3 ੉࢚ীࢲ ࢎਊоמ.
  32. 86

  33. 87

  34. ՘