Hi:
I just started to try kotlin with vert.x
I’ve heard some one would try it earlier, but then no news. So I start to do it myself now.
Currently there is more interest in integration with Play!, but I’ve found that they have already stopped new dev on Play! 1.x branch (which is java and excellent), and Play! 2.0 is pure Scala implemented, which IMHO might lead to some trouble, so when I found about vert.x, think that would be a good fit for kotlin. Vert.x is Plotglot natively !
I got the simplest HTTP hello world running OK now.
Will try to integrate kool-template so that I can actually make a web app. (Unlike Play! There is no dedicated template system in vert.x yet).
The code is in github if you are interested. https://github.com/zhaopuming/kert.x
I heard that some one has looked into this in one post earlier, but
I have some issues already:
1. Should I just wrap around vert.x code?
In vert.x java, there is no lambda, so they come up with a Hanlder<T> class used as a function, I've successfully wrapped some of there methods that takes a Handler<T> to a Kotlin function. Now the code looks like:
public override fun start() {
val server = this.getVertx()?.createHttpServer()!!
val routes = RouteMatcher()
routes.get(“/”, { (req) ->
req.response?.end(“Hello”)
})
server.requestHandler(routes as Handler<HttpServerRequest?>)
server.listen(8080, “localhost”)
}
But there remains a lot of T? in the code, where we may still have to deal with nullability. Is this a issue? Is it a good practice to ingore nullability when wrapping a Java lib?
2. for each methods that takes a Handler, I’ll have to make a duplicate to take a Kotlin function instead, but when using it we have to import that dup method. Is that the right way to go?
3. I haven’t used kool-template in vert.x yet. but I suppose it has no dependency on other libs and have no issue with classpath, right ?
Before thinking about kool-template, I was trying to integrate Rythm template (a good template engine in Play! framework), but in vain due to classpath problems. I have contacted Rythm’s author but he seems to be busy at the moment.
4. other than Hanlder wrapped with kotlin function and kool-template, I haven’t got any new ideas yet. What would you suggest.
finally, I need help from the community. I’m new to kotlin and have not much experience. Anyone interested in vert.x & kotlin integrated?