GWT and Kotlin?


#1

Is it possible to use Kotlin for both the server- and client-side of a Google Web Toolkit app?

I did a quick test and the server side was easy. But I could not get it to work on the client-side.
Anyone had any luck with that?

Kind regards
Anders


#2

Nope. The GWT compiler compiles Java source code to javascript. If it would have been bytecode it would have worked.


#3

Thanks for the answer. I didn't quite understand if Kotlin could produce Java source files as well as byte code.

Would be great if it could produce Java source files, then it should be possible to use in GWT.


#4

Xtend do it. It compiles Java source from xtend sources. Maybe it is what your are searching for. http://www.eclipse.org/xtend/ (I’m using it in some of my projects.)

Another possible solution is TeaVM. It compiles java bytecode to js, so it can be used to compile Java/Kotlin mixed apps. http://teavm.org/ (I haven’t used it, but you can take a try.)


#5

Thanks for the info. I didn’t know about TeaVM - looks interesting.


#6

Now that Kotlin 1.2 is released, it can be compiled into JS and we can have shared code between server and browser like GWT.


#7

in GWT 3.0 GWT RPC will be deprecated. But for those who want to do similar thing using kotlin, I think it’s possible by either using Vaadin-on-Kotlin or calling gRPC for Java from Kotlin-JVM and calling grpc-web from Kotlin-JS