Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin 2.0을 통해 알아보는 코틀린의 미래
Search
Leonardo YongUk Kim
May 24, 2023
Programming
1
2.5k
Kotlin 2.0을 통해 알아보는 코틀린의 미래
라인 테크 토크에서 공유한 "코틀린 2.0을 통해 알아보는 코틀린의 미래" 발표 자료입니다.
Leonardo YongUk Kim
May 24, 2023
Tweet
Share
More Decks by Leonardo YongUk Kim
See All by Leonardo YongUk Kim
Recap: Kotlin Language Features in 2.0 and Beyond (Michail Zarečenskij)
dalinaum
0
600
Compose Multiplatform 101
dalinaum
3
620
실리콘밸리 스타트업에서 일어난 일
dalinaum
0
120
AlphaGo에서 시작하는 인공지능
dalinaum
1
290
Zip: Data compression (20분만에 배우는 압축 알고리즘)
dalinaum
1
2.4k
안드로이드 빌드: 설탕없는 세계
dalinaum
0
140
Obfuscation 101 @ Naver Tech Concert
dalinaum
4
540
Realm은 어떻게 효율적인 데이터베이스를 만들었나?
dalinaum
1
560
MVC부터 MVVM, 단방향 데이터 흐름까지
dalinaum
5
850
Other Decks in Programming
See All in Programming
php-conference-japan-2024
tasuku43
0
410
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
140
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
280
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
970
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
720
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
360
Go の GC の不得意な部分を克服したい
taiyow
3
980
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.3k
Zoneless Testing
rainerhahnekamp
0
150
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
390
Androidアプリの One Experience リリース
nein37
0
690
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.1k
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
32
6.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
The Language of Interfaces
destraynor
155
24k
How to Ace a Technical Interview
jacobian
276
23k
Designing for humans not robots
tammielis
250
25k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Optimizing for Happiness
mojombo
376
70k
Site-Speed That Sticks
csswizardry
2
220
RailsConf 2023
tenderlove
29
960
Measuring & Analyzing Core Web Vitals
bluesmoon
5
190
Transcript
Kotlin 2.0 ਸ ా೧ ঌইࠁח Kotlin ې Leonardo YongUk
Kim 2023.05
2 Contents 01 02 03 04 05 Kotlin 2.0 ߂
୶оੋ য ച Kotlin Multiplatform Compose for iOS Compose for Desktop Compose for Web
1. Kotlin 2.0 ߂ ୶оੋ য ച
,ࣁ҅ীࢲفߣ૩۽֫,PUMJOীبੑغחۿূ٘
5 K2 ஹੌ۞ بੋ ۿূ٘ ೱ࢚ https://blog.jetbrains.com/ko/kotlin/2023/04/kotlinconf-2023-opening-keynote/
6 ۿূ٘৬ ߔূ٘о ޖੋоਃ? ۿ ূ٘ ࢲ৬ दݭ౮ গօۄ۽ ҳࢿ.
ࣗझ٘ܳ ੍য ҳޙ ܻܳ ٜ݅Ҋ ࠁܳ ୶оೣ. ߔূ٘ р ٘ ࢤࢿ & ୭ചӝ৬ ݠन ٘ ࢤࢿ ୭ ച۽ ա־য. ୭ചܳ ೞҊ ӝ҅য ٘ա ఋѶ ٘ܳ ࢤࢿ. ౣܽ ҃ীח ߄ Bytecodeա LLVM Bitcodeо ఋѶ. ౣܽ ౣܽ ҃ী (1.3ө) р ٘ ࢤࢿ & ୭ ചӝо হ. ബਯࠁח ౣܽ য ߊ ؊ ਃ೮. (ӝࣿࠗ) https://twitter.com/kotlin
7 ߔূ٘ী IR بੑ IR ߔূ٘ীࢲ ҕਬೞח р ࣻળ য
IR generator & optimizer IRਸ ٜ݅Ҋ ୭ച ೞח . ౣܽ ֎౭࠳ܳ ٜ݅ݴ ࢜܂ѱ ୶о. റ JVM(1.5)җ JS(1.6)ਸ IRਸ ॳب۾ ࢿ. ҕాੋ ୭ചܳ ೡ ࣻ . (Ӓө ח ߔূ٘݃ ߹ب۽ ࢿ.) بೞח ঋও݅ ࢜ ߔূ٘ ࢿמ ೱ࢚! https://twitter.com/kotlin
թ Ѫ ۿূ٘ ۨѢद PSI (Program Structure Interface) PSI Program
Structure Interface ౣܽ ٘ܳ यೠ Ѿҗ ܻ. IntelliJীࢲ ݢ ॳ؍ ҳઑܳ ౣܽ ஹੌ۞ب ରਊ. ࣗझ ٘৬ Ѣ غח ױࣽೠ ഋక.
PSIViewer۽ PSIܳ ഛੋ оמ
ܳ ח BindingContext Kotlin Compiler In past, 1.4 and beyond
ܳ ח BindingContext Kotlin Compiler In past, 1.4 and beyond
ܳ ח BindingContext Kotlin Compiler In past, 1.4 and beyond
PSI + BindingContextо ޙઁо աਃ? ୭ച ۿূ٘ ࣻળীࢲ PSIীࢲ ୭ചܳ
ೞח Ѫ औ ঋ. ޙݓ ߹ب BIndingContextী ח Ѫب ୭ചী જ ޅೣ. நए झ BindingContextо Ѣೠ Mapযࢲ நए ബਯী જ ޅೣ.
Frontend Intermediate Representation ߔূ٘ীѱ ׳ೡ ࢜۽ р য https://twitter.com/kotlin
Kotlin FIR Viewer FIRਸ ࠅ ࣻ ח ࠭য https://github.com/google/Kotlin-FirViewer
Kotlin Compiler In past, 1.4 and beyond
ۿূ٘ ৵ FIR فѐо աਃ? ࢲ 3BX'*3࠽؊ "OBMZ[F ழ झܻ
'*3 '*3 ױ Lowering ױࣽച(simplify)ۄҊ ࢸݺ. ٣गѢ݂(Desugraing)ۄҊب അ. ࠺ҳઑച (Desctructure)ܳ োࣘػ ੑਵ۽ ߸҃. for ١ਸ whileਵ۽ ߸҃. ো(+, +=, in, …)١ਸ ݺदੋ ഐ۽ ߸ഋ. ӝఋ ۿূ٘ ࣻળীࢲ ୭ചب ࣻ೯.
18 FIR ӝ߈ ۿূ ஹੌ۞ ࢿמ FIR ӝ߈ਵ۽ ݅ٚ
ۿূ٘ח PSI + BindingContext ӝ߈ ۿূ٘ ࠁ ഻न ࡅܴ. IDE IDEب ۿূ٘ܳ ҕਬ. ੋభܻઁীࢲ ܳ ঈೞҊ ٘ ೞۄ, ࠙ࢳೞח ࣘبо ࡈۄ. Kotlin IDE ۞Ӓੋ ࢿ.
19 о ݆ ਃ߉ ӝמ Static Extensions ੋझఢझо ইפ؊ۄب ഛ
ೣࣻܳ ٜ݅ ࣻ . Collection Literals listOf, mapOf, setOf о ইצ ܻఠۡ۽ ஸ۩࣌. Name-based Destructuring ࠺ҳઑച(ҳઑ࠙೧)ܳ ਤ ӝ߈ ইפۄ ܴ ӝ߈ਵ۽. Explicit Fields э ஶࣆ private, public ۽ಌ౭ܳ ٜ݅ ঋইب ؽ. Context Receivers ݯߡ ഛ ೣࣻ ৻ী Contextܳ ೡ ߑߨ ୶о.
20 ഛ (Static Extensions) https://youtrack.jetbrains.com/issue/KT-11968 File.open("data.txt")
21 ഛ (Static Extensions) https://youtrack.jetbrains.com/issue/KT-11968 File.open("data.txt") fun File.Companion.open(name: String)
22 ഛ (Static Extensions) https://youtrack.jetbrains.com/issue/KT-11968 File.open("data.txt") fun File.Companion.open(name: String)
23 ഛ (Static Extensions) https://youtrack.jetbrains.com/issue/KT-11968 File.open("data.txt") fun File.Static.open(name: String)
24 ஸ۩࣌ ܻఠۡ (Collection Literals) https://youtrack.jetbrains.com/issue/KT-43871 cmdArgs = listOf("-language-version", "2.0")
25 ஸ۩࣌ ܻఠۡ (Collection Literals) https://youtrack.jetbrains.com/issue/KT-43871 cmdArgs = [“-language-version", “2.0"]
26 ஸ۩࣌ ܻఠۡ (Collection Literals) https://youtrack.jetbrains.com/issue/KT-43871 cmdArgs = [“-language-version", “2.0”]
val skip = persistentSetOf<Int>(0, 1)
27 ஸ۩࣌ ܻఠۡ (Collection Literals) https://youtrack.jetbrains.com/issue/KT-43871 cmdArgs = [“-language-version", “2.0”]
val skip: PersistentSet<Int> = [0, 1]
28 ஸ۩࣌ ܻఠۡ (Collection Literals) https://youtrack.jetbrains.com/issue/KT-43871 cmdArgs = [“-language-version", “2.0”]
val skip = PersistentSet [0, 1]
29 ܴ ӝ߈ ࠺ҳઑച (Name-Based Restructuring) https://youtrack.jetbrains.com/issue/KT-19627 data class Person(
val fi rstName: String, val lastName: String )
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
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
32 ஶఖझ ࣻन (Context Receivers) https://youtrack.jetbrains.com/issue/KT-10468 fun process( context: ServiceContext,
request: ServiceRequest ) { val data = request.loadData(context) }
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)
34 ஶఖझ ࣻन (Context Receivers) https://youtrack.jetbrains.com/issue/KT-10468 context(ServiceContext) fun processRequest(request: ServiceRequest)
{ val data = request.loadData() // }
35 ஶఖझ ࣻन (Context Receivers) https://youtrack.jetbrains.com/issue/KT-10468 context(ServiceContext) fun processRequest(request: ServiceRequest)
{ val data = request.loadData() // } context(ServiceContext) fun ServiceRequest.loadData(): Data
36 ݺद ٘ (Explicit Fields) https://youtrack.jetbrains.com/issue/KT-14663 private val _applicationState =
MutableStateFlow(State()) val applicationState: StateFlow<State> get() = _applicationState
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())
38 ؘఠۨ https://github.com/kotlin/dataframe val df = DataFrame.readCSV("KotlinSO.csv")
39 ؘఠۨ https://github.com/kotlin/dataframe val df = DataFrame.readCSV("KotlinSO.csv") val kmp =
df. fi lter { tags?.contains("multiplatform") ?: false }
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()
41 ؘఠۨ
2. Kotlin Multiplatform
43 ݒ֙ ݣ౭ۖಬ ۄ࠳۞ܻח ૐо.
44 ౣܽ ݣ౭ۖಬ ই ߬ఋ ױ҅
45 Kotlin Multiplatform ۄ࠳۞ܻ
46 Kotlin Multiplatform Mobileਸ ਤ೧ ਃೠ Ѫ Android Studio ݣ౭ۖಬ
গܻா࣌ਸ ٜ݅Ҋ दޛۨఠա ೞ٘ਝযܳ प೯.
47 Kotlin Multiplatform Mobileਸ ਤ೧ ਃೠ Ѫ Xcode Xcodeח ߔӒۄ٘ীࢲ
ࣻ೯ ؽ. Kotlin/Nativeо ઓೞח ߡਸ ࢸ೧ঠ ೣ.
48 Kotlin Multiplatform Mobileਸ ਤ೧ ਃೠ Ѫ Kotlin Multiplatform Mobile
উ٘۽٘ झౚ٣য়ীࢲ Kotlin Multiplatform Mobile ۞Ӓੋ ࢸ.
49 Kotlin Multiplatform Mobileਸ ਤ೧ ਃೠ Ѫ JDK Android Studioী
೧ ࢸ. Kotlin Plugin Android Studioী ࢸ. সؘܳ ೧ࢲ ߡਸ ୭नച ೧ঠ.
50 Kotlin Multiplatform Mobileਸ ਤ೧ ਃೠ Ѫ KDoctor KMMਸ ਤ೧
ਃೠ ജ҃ ח Ѩೞח জ.
51
52 Kotlin Multiplatform Mobileਸ ਤ೧ ਃೠ Ѫ CocoaPods KMM SPM(SwiftPackageManager)ܳ
ਗೞ ঋ. ( ৵!)
53 Kotlin Multiplatform Appਵ۽ ࢜ ۽ંܳ ݅ٞ.
54 ಁః ֎ উ٘۽٘/߄ জۢ بݫੋ ࣽਵ۽ ೣ.
55 জ ֎ ӝࠄਵ۽ androidApp, iosApp, shared۽ জ ֎ ೧.
iOS framework distribution Regular۽ Cocoapods -_-ਸ ࢶఖೡ ࣻ .
56 androidApp উ٘۽٘ ҙ۲ ٘ח androidApp ইې ਤೣ
57 উ٘۽٘ח Compose۽ ࢤࢿ ؽ
58 iosApp iOS ҙ۲ ٘ח iOSAppী ਤೣ.
59 iOSח SwiftUI۽ Compose ইתפ.
60
61 ߡ ܻח যڌѱ ೮ਸөਃ? expect৬ actual shared/src/ commonMain iOS৬
Androidীࢲ ݽف ࢎਊೡ ੋఠಕझܳ expect ఃਕ٘۽ ݅ٞ.
62 ߡ ܻח যڌѱ ೮ਸөਃ? expect৬ actual shared/src/ androidMain Android
ҳഅਸ actual ఃਕ٘ܳ ࠢৈ ҳഅ
63 ߡ ܻח যڌѱ ೮ਸөਃ? expect৬ actual shared/src/ iOSMain iOS
ҳഅਸ actual ఃਕ٘ܳ ࠢৈ ҳഅ
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ܳ ೧ঠ ೣ.
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 ۽ಌ౭ח ݫੋझۨ٘ীࢲ݅ ࠅ ࣻ .
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
3. Compose for iOS
68 Compose Multiplatform mobile application మ݁ਸ ਊ೧ࢲ द೧ঠ మ݁ https://github.com/JetBrains/compose-multiplatform-ios-android-template
69 Compose for iOSܳ ਤ೧ ਃೠ Ѫ Android Studio Android
জҗ iOS জܳ प೯ೡ ࣻ ח ѐߊ ജ҃. Xcode Xcodeח ߔӒۄ٘ীࢲ ࣻ೯ ؽ. Kotlin/Nativeо ઓೞח ߡਸ ࢸ೧ঠ ೣ. Kotlin Multiplatform Mobile উ٘۽٘ झౚ٣য়ীࢲ Kotlin Multiplatform Mobile ۞Ӓੋ ࢸ. CocoaPods Compose for iOSب SPM(SwiftPackageManager)ܳ ਗೞ ঋ.
70 Compose for iOSܳ ਤ೧ ਃೠ Ѫ
71 shared/src/ commonMain
72 androidApp/ src/ commonMain
73 iosApp/ iosApp
74 iosApp/ iosApp
75 sharedApp/ src/iosMain
76 ߸҃೧ࠁח Compose for iOS TextField ୶о TextFieldܳ ୶оೞח
ؘݽܳ द.
4. Compose for Desktop
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 ࢚ীࢲ ࢎਊоמ.
79 Compose for Desktop ౠ ଵҊ࢚ You can do desktop
too! By Victor Kropp https://www.youtube.com/watch?v=Mgf_9kxM1BA JDK 15 JDK11ਵ۽ ۽ં ࢤࢿ оמ. ֎౭࠳ ߓನ ಁఃਸ ਤ೧ࢲח 15 ࢚.
80 Compose Multiplatform desktop application New Project۽ दೞӝ
81
82
5. Compose for Web
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 ࢚ীࢲ ࢎਊоמ.
85 WASM ઁ https://github.com/Kotlin/kotlin-wasm-examples
86
87