Questions about the Javascript API

Hi,

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…

  1. 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.  

  2. 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.

  3. 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.

thanks,
Rob

[1] http://jetbrains.github.io/kotlin/versions/snapshot/apidocs/index.html

Hi, Robert.

Unfortunately right now we don’t have documentations for that, but You can see code here https://github.com/JetBrains/kotlin/tree/master/js/js.libraries/src
And I collected some useful links, I hope this will help you:
http://blog.jetbrains.com/kotlin/2013/10/writing-kotlin-in-the-browser/

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.

Anyway feel free to ask any question here or directly me(zalim.bashorov@jetbrains.com).

Thanks, that will get me started.