Kotlin for JS

By pjain      Published Dec. 17, 2019, 1:46 a.m. in blog Programming   

Kotlin JS 101

KEY: It is VERY Early days for kJS - experimental - Stay Away

Kotlin compiling to JavaScript is wonderful. However it is still very experimental and things seem to change every few months. Is this right for the current state?

Basic foundational features are all present. Interop, actual compiling, etc

Working with libraries is still painful. You either rely on writing your own bindings, or rely on experimental plugins which may or may not work.

The Kotlin frontend plugin is deprecated and replaced with enhancements to the JS plugin.

Said enhancements (NPM dependencies, automatic header generation) are still very experimental and have some issues.

I tried using the automatic header generation with jquery and it crashed the plugin

Why kt/JS - interop with kt: ios+andr if THEY succeed

  • JS modules
  • Dynamic types vs k normal
  • DefinitelyTyped headers <-- typescript, etc
  • interop with react components .. see YT https://www.youtube.com/watch?v=pjnHDXkeK-4 at TS~16'

  • Android.github.io/kotlin-guides

  • docs

~15-20% less code, More mature codebase, cleaner, more null-safe * TODO: Use kotlin annotations for its null safety - throughout API interfaces

Cos: Google, Pinterest, Expedia, Basecamp, Robinhood 17% of new apps on k in Q1'18

AR - Levels of JS

  • Real simple JS + tiny JQuery

  • Complex DOM manipulation, heavy JQuery use

  • ES6, TS needed to keep JS logic sanity

Anything more - kotlin fnl - getting super complicated

r AR, Why Why not

r Kotlin for JS

KotlinConf 2017 - How to Build a React App in Kotlin by Dave Ford - YouTube KotlinConf 2017 - Frontend Kotlin from the Trenches by Gaetan Zoritchak - YouTube

https://github.com/Kotlin/js-externals https://github.com/Kotlin/kotlinx.html

kJS, Web Support in K1.1, k1.2

k1.1 introducing support for the JavaScript target in Kotlin 1.1, https://www.infoq.com/news/2017/03/kotlin-11-released

Kotlin now brings developers the possibility to easily manage projects meant to run both on the JVM and the JavaScript platforms.

kJS Quikstart


0 comments

There are no comments yet

Add new comment

Similar posts

Serverless Computing

Android Layouts Design 101

Drawing, Canvas in Kotlin

Custom Views