I thinking of using Kotlin on a couple web app projects. Having a type safe language in place of Javascript is very appealing, but I have a few questions…
Are the Javascript APIs documented somewhere? The only thing I found is the “kotlin.browser” package listed here [1], but I can’t import that. I was able to import js.dom.html.document, and there appear to be some other packages available under “js”, but I can’t see what’s there.
Is there an explanation somewhere of how I might use a class on both the client and server side? This comes up in data transfer. In my current web apps, I send an AJAX request, query a relational database, get back a type-safe object representing the result rows, and then send that over the wire as JSON, where I can then get runtime errors in Javascript for trivial type errors like mispelled property names. It’s really annoying, and if there is a way in Kotlin to pass those data objects to the browser and use them there with type safety, I’d start using Kotlin now.
If I need to write a “native” JS method to accomplish #2, I might do it, but again… I need documentation on how to do that. I don’t see any documentation on the Javascript stuff.
I can handle some early adopter pain, but I want to focus mostly on writing an application.
We work on new API reference for both backends and big part of current stdlib will be available in the future for JS backend too.
2. I don't know about any project where Kotlin used in both side.
In IDEA you can create two unrelated projects and set up a module in each of these using the same source directory, but different targets.
Additionally You can try do it by ant or maven build by sharing source dirs between different ant/maven projects.