Kotlin Intro & Starting the Koans

Tomás Hanley

17th Sept 2018

What is Ktor?

  • Framework for creating Web applications in Kotlin

  • Written in Kotlin

  • Sponsored and developed by JetBrains

Git History

  • First commit in Oct 2014

  • Currently on version 0.94

"Ktor is a framework for building asynchronous servers and clients in connected systems using the powerful Kotlin language"

Kotlin Adoption

  • Widely adopted for android development

  • Somewhat more cautious adoption for server side development

Why use Kotlin?

  • Kotlin is a better language for the JVM than Java
    • Really easy to get up and running
    • Simpler language than Java
    • Much safer than Java

      • No more NullPointerExceptions!

      • Streamlines the handling of null values

    • More more clean & concise than Java

    • 100% Interoperable with Java

      • Kotlin & Java classes can live side by side

Lots of web frameworks available

  • Spring MVC/WebFlux, Vert.x

  • Anything thats available on the JVM

Benefits of a Kotlin framework like Ktor

  • Makes heavy use of Coroutines for high scalability

  • Easy-to-use and idiomatic API

    • Type safe builders (DSLs)

Ktor

  • Really Lightweight

  • Extensible through features

    • Functionality that is injected into the request and response pipeline

Demo

Android Controller

  • Control drone with existing android app

    • Take off, Land

    • Control pitch, yaw, roll, etc.

  • Converted it to Kotlin & cleaned it up

Drone Controller

  • Send higher level commands to drone

    • Move one unit in any direction

    • Fly to coordinate (x, y)

    • Experimented with Coroutines

Consumer Service

  • Embedded Web Servers

  • Handle http requests

  • Experimenting with Ktor!

Asynchronous Kotlin Web Server with Ktor

By Tom Hanley

Asynchronous Kotlin Web Server with Ktor

  • 181