Kotlin Everywhere

Kotlin Everywhere

6923bdeb363961b064d2cdb6329982d6?s=128

Roberto Orgiu

July 20, 2018
Tweet

Transcript

  1. Kotlin everywhere

  2. Who’s speaking Rob @ NYT Boris @ ClearScore 2

  3. #CPIT2 sli.do Join the discussion

  4. Where https://pusher.com/state-of-kotlin

  5. Desktop apps with a little bit of Tornado™

  6. • JavaFX • Beautiful DSL • UI + Background thread

    • Injection • REST • Field validation • Can work™ with JS TornadoFX 6
  7. tornadofx.io goo.gl/qSjBPG goo.gl/gcrZss

  8. iOS apps and Android (but we wanted the WOW moment)

  9. Kotlin Native COMMON no platform specific dependencies class/function declaration 9

    PLATFORM implementations of platform-dependent declarations in the common module always an implementation of a single common module REGULAR targets specific platform can be dependency of platform modules can depend on platform modules
  10. 10

  11. ◇ common module defines expected declarations ◇ expected declarations never

    contain any implementation code 11 expected
  12. 12 actual ◇ platform module provides actual declarations ◇ actual

    declarations must match expected declarations
  13. 13 package org.jetbrains.foo expect class Foo(bar: String) { fun frob()

    } fun main(args: Array<String>) { Foo("Hello").frob() }
  14. 14 package org.jetbrains.foo actual class Foo actual constructor(val bar: String)

    { actual fun frob() { println("Frobbing the $bar") } }
  15. JVM Backend

  16. 16

  17. Javascript Both Frontend and Backend!

  18. 18

  19. 19

  20. ◇ You can set and call everything you want on

    properties of this type ◇ Disables compiler checks (beware of runtime errors) 20 dynamic
  21. ◇ Kotlin assumes the implementation is provided by the developer

    (in JS) ◇ The compiler will not generate JS code for this function ◇ No auto completion 21 external
  22. 22 external fun require(module: String): dynamic fun main(args: Array<String>) {

    val app = require(“express”) app.get(“/hello”, {req, res -> res.send(“Hello world!”) }) }
  23. } 23 { Kotlin wrappers

  24. 24 @JsModule(“express”) external class Express { fun get( route: String,

    callback: (req: Request, res: Response) -> Unit ) external class Request external class Response { fun send(data: String) } }
  25. } 25 { Kotlin wrappers https://github.com/JetBrains/kotlin-wrappers

  26. Thanks! Any questions? You can find us at: ◇ @_tiwiz

    ◇ @borisdamato 26