I'm very interested in being able to share code between JS and JVM, but there are currently a few things in the way of this.
- Projects have to either be JS or JVM, so any code you intend to be for both needs to be built via build tool and not the IDE
JS library support isn't quite there -
- Is there a way to have JS library dependencies with ant?
- Is there a way to produce a JS Jar?
- There are a few differences between JS and JVM code that I would consider to be 'core' to the language.
- Annotations in JS projects will not compile
- There is no common code for number constants such as POSITIVE_INFINITY, NaN, etc. Copying the number constants from Java will compile in JS, but not in JVM (Divide by zero errors)
- Certain features such as inner classes exist in JVM but not JS
One of the bullet points for Kotlin on the homepage is "Versatile - Suitable for any type of application. Even for sharing code between JVM/JS". I don't think this is currently a true statement, but I hope it will be soon!
A number of these issues are already in issue tracker, and I will try to add more as I see them. What I would love to see is just general progress towards the ability to share code between JS/JVM projects.