let kotlin v2 - goto conference · set up gradle-kotlin plugin and apply it. add dependencies....
TRANSCRIPT
![Page 2: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/2.jpg)
@TTGonda
WHO AM I?▸ Android Engineer at Buffer
▸ Author at Ray Wenderlich
▸ Chicago
▸ Dancer
![Page 3: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/3.jpg)
@TTGonda
![Page 4: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/4.jpg)
“STATICALLY TYPED PROGRAMMING LANGUAGE FOR MODERN MULTIPLATFORM APPLICATIONS”
kotlinlang.org
![Page 5: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/5.jpg)
@TTGonda
KOTLIN▸ Developed by JetBrains
▸ Available for JVM, Android, JavaScript, and Native
▸ Concise, safe interoperable, tool-friendly
▸ Built in IDE support (with JetBrains products)
![Page 6: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/6.jpg)
@TTGonda
KOTLIN▸ Strong, static, inferred, null safe typing
▸ Immutability by default
▸ Smart casting
▸ Higher order functions
▸ Boilerplate reduction
![Page 7: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/7.jpg)
TYPING
![Page 8: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/8.jpg)
@TTGonda
STATICALLY TYPED
final String name = "Victoria";
val name = "Victoria"
![Page 9: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/9.jpg)
@TTGonda
NULL TYPING
val icecream: IceCream?
![Page 10: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/10.jpg)
@TTGonda
icecream.flavor
![Page 11: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/11.jpg)
@TTGonda
if (icecream != null) { return icecream.flavor} else { return null}
![Page 12: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/12.jpg)
@TTGonda
SAFE CALL OPERATOR
return icecream?.flavor
![Page 13: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/13.jpg)
@TTGonda
!! OPERATOR
return icecream!!.flavor
![Page 14: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/14.jpg)
@TTGonda
ELVIS OPERATOR
return icecream?.flavor ?: "Chocolate Chip"
![Page 15: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/15.jpg)
@TTGonda
NULL SAFE SCOPING WITH HIGHER ORDER FUNCTIONS
return icecream?.let({ nonNullIceCream -> nonNullIceCream.flavor })
return icecream?.let({ it.flavor })
return icecream?.let { it.flavor }
return icecream?.let(IceCream::flavor)
![Page 16: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/16.jpg)
IMMUTABILITY
![Page 17: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/17.jpg)
@TTGonda
val conference = "GOTO Chicago"
conference = "GOTO Chicago 2018”
![Page 18: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/18.jpg)
@TTGonda
var conference = "GOTO Chicago"
conference = "GOTO Chicago 2018”
![Page 19: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/19.jpg)
@TTGonda
val readOnlylist = listOf(1, 2, 3)
val mutableList = mutableListOf("a", "b", “c")
![Page 20: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/20.jpg)
SMART CASTING
![Page 21: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/21.jpg)
@TTGonda
SMART CASTING
class Conference(val year: String): Event()
fun smartCasting(event: Event) { if (event is Conference) { event.year } }
![Page 22: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/22.jpg)
BOILERPLATE REDUCTION
![Page 23: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/23.jpg)
@TTGonda
class Cupcake( val flavor: String, var icing: String?)
CLASSES
![Page 24: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/24.jpg)
@TTGonda
public final class Cupcake { @NotNull private final String flavor; @Nullable private String icing;
@NotNull public final String getFlavor() {}
@Nullable public final String getIcing() {}
public final void setIcing(@Nullable String var1) {}
public Cupcake(@NotNull String flavor, @Nullable String icing) {}}
![Page 25: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/25.jpg)
@TTGonda
data class Cupcake( val flavor: String, var icing: String?)
![Page 26: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/26.jpg)
@TTGonda
public final class Cupcake { // …
@NotNull public final String component1() {}
@Nullable public final String component2() {}
@NotNull public final Cupcake copy(@NotNull String flavor, @Nullable String icing) {}
public String toString() {}
public int hashCode() {}
public boolean equals(Object var1) {}}
![Page 27: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/27.jpg)
SEALED CLASSES
![Page 28: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/28.jpg)
@TTGonda
ENUMS
enum class GetConferenceState { SUCCESS, ERROR, PROGRESS }
![Page 29: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/29.jpg)
@TTGonda
SEALED CLASSES
sealed class GetConferenceState {
class Success(val result: Conference): GetConferenceState()
data class Error(val errorMessage: String): GetConferenceState()
object InProgress: GetConferenceState() }
![Page 30: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/30.jpg)
@TTGonda
SEALED CLASSES
when(state) {
is GetConferenceState.Success -> showConference(state.conference)
is GetConferenceState.Error -> showError(state.errorMessage)
is GetConferenceState.InProgress -> showLoading() }
![Page 31: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/31.jpg)
@TTGonda
AND MORE!
![Page 32: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/32.jpg)
@TTGonda
![Page 33: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/33.jpg)
WHERE CAN KOTLIN BE USED?
![Page 34: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/34.jpg)
@TTGonda
WHERE CAN KOTLIN BE USED?▸ JVM, Android, JavaScript, Native
▸ Mobile, Server, Browser, Views
▸ IntelliJ, Android Studio, Eclipse, Standalone Compilers
▸ Kotlin all the things!
▸ Try it out in the browser (try.kotlinlang.org)
![Page 35: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/35.jpg)
@TTGonda
JAVA VIRTUAL MACHINE▸ Use on the server, Android, Java applications
▸ Spring Boot, for example
▸ Anywhere the JVM lives
▸ Interoperable with Java
▸ More flexible and concise than Java
▸ Less feature bloat than Scala
![Page 36: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/36.jpg)
@TTGonda
JVM - INTELLIJ
![Page 37: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/37.jpg)
@TTGonda
JVM - INTELLIJ▸ New Kotlin file in src directory
fun main(args: Array<String>) { println("Hello GOTO Chicago") }
▸ Run! ▶
![Page 38: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/38.jpg)
@TTGonda
JVM - GRADLE▸ Set up gradle-kotlin plugin and apply it. Add dependencies.
repositories { mavenCentral() }
dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib" }
▸ Alternatively in IntelliJ, Tools > Kotlin > Configure Kotlin in Project
![Page 39: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/39.jpg)
@TTGonda
JVM - ECLIPSE▸ Download plugin from Marketplace
▸ File > New > Kotlin Project
![Page 40: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/40.jpg)
@TTGonda
JVM - ECLIPSE▸ New Kotlin file in src directory
fun main(args: Array<String>) { println("Hello GOTO Chicago") }
▸ Run As > Kotlin Application ▶
![Page 41: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/41.jpg)
@TTGonda
JVM - COMMAND LINE▸ Install Kotlin
// hello.kt fun main(args: Array<String>) { println("Hello GOTO Chicago") }
▸ Run! ▶
$ kotlinc hello.kt -include-runtime -d hello.jar $ java -jar hello.jar
![Page 42: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/42.jpg)
@TTGonda
JAVA EQUIVALENT
public final class HelloKt { public static final void main(@NotNull String[] args) { Intrinsics.checkParameterIsNotNull(args, "args"); String var1 = "Hello GOTO Chicago"; System.out.println(var1); } }
![Page 43: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/43.jpg)
@TTGonda
CONVERTING JAVA TO KOTLIN▸ Android Studio and IntelliJ have built in conversion
▸ Three ways to get there
▸ Code > Convert Java File to Kotlin File
▸ ⎇⇧⌘K
▸ Search for action “Convert File to Kotlin File
![Page 44: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/44.jpg)
@TTGonda
JVM - OTHER OPTIONS▸ Ant
▸ Maven
▸ Griffon
![Page 45: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/45.jpg)
@TTGonda
ANDROID▸ More flexible and concise than Java
▸ Interoperable with Java
▸ Can use all the same libraries
▸ Supported in Android Studio
![Page 46: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/46.jpg)
@TTGonda
ANDROID STUDIO
![Page 47: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/47.jpg)
@TTGonda
JAVASCRIPT▸ Use in browser, and any JS framework
▸ ReactJS, for example
▸ Type safe
▸ Interop with JavaScript
![Page 48: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/48.jpg)
@TTGonda
JS - INTELLIJ
![Page 49: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/49.jpg)
@TTGonda
JS - INTELLIJ▸ New Kotlin file in src directory
fun main(args: Array<String>) { println("Hello GOTO Chicago") }
![Page 50: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/50.jpg)
@TTGonda
JS - INTELLIJ▸ Create index.html that runs script
<script type="text/javascript" src=“out/production/sampleapp/lib/kotlin.js"> </script> <script type="text/javascript" src=“out/production/sampleapp/sampleapp.js"> </script>
▸ Build > Build Application
▸ Open index.html in browser ▶
![Page 51: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/51.jpg)
@TTGonda
JS - COMMAND LINE▸ Library code is in library.kt
kotlinc-js -output sample-library.js -meta-info library.kt
▸ Output:
sample-library.js sample-library.meta.js
![Page 52: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/52.jpg)
@TTGonda
JS - OTHER OPTIONS▸ Gradle
▸ Maven
![Page 53: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/53.jpg)
@TTGonda
VIEWS▸ Use kotlinx.html library to interact with, and build HTML views
▸ Use Anko to build views for Android
▸ You can use Kotlin for the logic of what to display in your views!
![Page 54: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/54.jpg)
@TTGonda
VIEWS▸ kotlinx.html
val myDiv = document.create.div { p { +"text inside" } }
![Page 55: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/55.jpg)
@TTGonda
NATIVE▸ Available for macOS, Linux and Windows
▸ LLVM
▸ Interop with C libraries
![Page 56: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/56.jpg)
@TTGonda
NATIVE - COMMAND LINE▸ Download compiler for your OS
▸ Create file hello.kt
fun main(args: Array<String>) { println("Hello GOTO Chicago") }
▸ Compilekonanc hello.kt
▸ Run ▶/hello.kexe
![Page 57: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/57.jpg)
@TTGonda
NATIVE - OTHER OPTIONS▸ CLion IDE
▸ Gradle
![Page 58: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/58.jpg)
MULTI PLATFORM
![Page 59: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/59.jpg)
@TTGonda
MULTI PLATFORM▸ Share logic across platforms
▸ Write once, use everywhere
▸ Keep native for any framework components
▸ Note: experimental
![Page 60: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/60.jpg)
@TTGonda
MULTI PLATFORM▸ Common module with code shared across
platforms
▸ Platform specific module
▸ “Interface” for the common code to call platform specific implementations
http://developine.com/kotlin-native-ios-development-multiplatform-project/
![Page 61: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/61.jpg)
@TTGonda
MULTI PLATFORM - INTELLIJ
![Page 62: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/62.jpg)
@TTGonda
commonKotlin
JVMKotlin
JSKotlin
*.class *.js
![Page 63: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/63.jpg)
@TTGonda
// In common module expect class Dog(bar: String) { fun bark() }
fun main(args: Array<String>) { Dog(“Spot").bark() }
// In platform module actual class Dog actual constructor(val name: String) { actual fun bark() { println(“$name says ruff”) } }
![Page 64: Let Kotlin v2 - GOTO Conference · Set up gradle-kotlin plugin and apply it. Add dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib"](https://reader033.vdocuments.site/reader033/viewer/2022042312/5edae3c709ac2c67fa68798a/html5/thumbnails/64.jpg)
@TTGonda
GET STARTED!▸ kotlinlang.org 💯 docs
▸ try.kotlinlang.org to try Kotlin in the browser
▸ kotlin.link to find anything Kotlin you might want
▸ github.com/vgonda/Talk-Resources my resources from this talk (and others)
▸ Kotlin Slack
▸ Find me online!