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

Kotlin for fullstack web/apps development

Toan Tran
December 18, 2020

Kotlin for fullstack web/apps development

This talk covers the idea of having Kotlin to support in building multiple-component applications. With Kotlin's help, your Backend, Frontend, and Mobile all written in the same language, shares the same business model and domain objects, re-used the business rules and validations.
The talk also comes up with a sample code demonstration to understand how this could be realized.

Toan Tran

December 18, 2020
Tweet

More Decks by Toan Tran

Other Decks in Programming

Transcript

  1. View Slide

  2. About speaker
    Hello! I’m Toan
    Kotlin GDE, Android folk @Lazada
    https://toan.mobi
    toantran-ea
    toan_mobi

    View Slide

  3. Kotlin for fullstack web/apps development
    1. What is Kotlin? (2 mins
    )
    2. Why Kotlin? (5 mins
    )
    3. Kotlin multiple platform to power us (10 mins
    )
    4. Deep-dive into code to understand KMP (15 mins
    )
    5. Key-takeaways. (3 mins
    )

    View Slide

  4. What is Kotlin
    The Kotlin language project started in 2010 and soon went
    open-source

    View Slide

  5. Kotlin evolution
    v1.0: stable release
    v1.1: coroutines (experimental
    )
    v1.2: Kotlin multiple platforms/Kotlin native (experimental)
    v1.3: coroutine (stable
    )
    v1.4: Performance improvement

    View Slide

  6. GDG Location
    Why Kotlin?
    Expressiveness Safety
    Interoperability Structured
    concurrency

    View Slide

  7. class MainActivity : AppCompatActivity () {
    override fun onCreate(savedInstanceState: Bundle?) {
    ...
    fab.setOnClickListener { view ->
    Snackbar.make(view,
    "Hello ${name.capitalize()}",
    Snackbar.LENGTH_LONG).show()
    }
    fab.backgroundTintList = backgroundTintList
    }
    }
    Why Kotlin?

    View Slide

  8. class MainActivity : AppCompatActivity () {
    override fun onCreate(savedInstanceState: Bundle?) {
    ...
    fab.setOnClickListener { view ->
    Snackbar.make(view,
    "Hello ${name.capitalize()}",
    Snackbar.LENGTH_LONG).show()
    }
    fab.backgroundTintList = backgroundTintList
    }
    }
    Nullability in the
    type system
    Why Kotlin?

    View Slide

  9. class MainActivity : AppCompatActivity () {
    override fun onCreate(savedInstanceState: Bundle?) {
    ...
    fab.setOnClickListener { view ->
    Snackbar.make(view,
    "Hello ${name.capitalize()}",
    Snackbar.LENGTH_LONG).show()
    }
    fab.backgroundTintList = backgroundTintList
    }
    }
    Nullability in the
    type system
    Lambdas
    Why Kotlin?

    View Slide

  10. class MainActivity : AppCompatActivity () {
    override fun onCreate(savedInstanceState: Bundle?) {
    ...
    fab.setOnClickListener { view ->
    Snackbar.make(view,
    "Hello ${name.capitalize()}",
    Snackbar.LENGTH_LONG).show()
    }
    fab.backgroundTintList = backgroundTintList
    }
    }
    Nullability in the
    type system
    Lambdas
    Extension
    functions
    Why Kotlin?

    View Slide

  11. class MainActivity : AppCompatActivity () {
    override fun onCreate(savedInstanceState: Bundle?) {
    ...
    fab.setOnClickListener { view ->
    Snackbar.make(view,
    "Hello ${name.capitalize()}",
    Snackbar.LENGTH_LONG).show()
    }
    fab.backgroundTintList = backgroundTintList
    }
    }
    Nullability in the
    type system
    Lambdas
    Template
    expressions
    Extension
    functions
    Why Kotlin?

    View Slide

  12. class MainActivity : AppCompatActivity () {
    override fun onCreate(savedInstanceState: Bundle?) {
    ...
    fab.setOnClickListener { view ->
    Snackbar.make(view,
    "Hello ${name.capitalize()}",
    Snackbar.LENGTH_LONG).show()
    }
    fab.backgroundTintList = backgroundTintList
    }
    }
    Nullability in the
    type system
    Lambdas
    Template
    expressions
    Extension
    functions
    Property access
    syntax for getters
    and setters
    Why Kotlin?

    View Slide

  13. The major usage of Kotlin right now

    View Slide

  14. In my “ideal world”
    Cross-functional team model

    View Slide

  15. How Kotlin Multiple Platform could help?
    1. JVM Code
    2. JS Code
    3. Native Code
    4. Common Kotlin

    View Slide

  16. KMP - Common Kotlin
    1. The language, core libs, basic
    tools to serve all the platform.
    2. Rely on daily-task support
    tools like Http, serialization,
    and managing coroutines.

    View Slide

  17. Platform specific version of Kotlin
    1. Kotlin/JVM, Kotlin/JS,
    Kotlin/Native: Platform
    specific libs and tools.

    View Slide

  18. Structure of shared code

    View Slide

  19. Structure of shared code

    View Slide

  20. Structure of shared code

    View Slide

  21. Code demo - Project 1

    View Slide

  22. Code demo - Project 2

    View Slide

  23. Key takeaways
    1. Production ready? yes! (KotlinConf 2019: Kotlin in Space by Maxim
    Mazin)
    2. Not everything can be shared
    a. To share: Data, View Model, Validations, Utils, View Model, RPC,
    Common Libs
    b. Not to share: UI, Data storage

    View Slide

  24. Key takeaways
    3. Where to start? with sample
    a. Mobile KMP: Kotlin Conf app
    b. JS/JVM: [email protected]:kotlin-hands-on/jvm-js-fullstack.git
    c. Another one:
    [email protected]:Kotlin/kotlin-full-stack-application-demo.git
    4. Start with step-by-step guide: here

    View Slide

  25. Thank you

    View Slide