Mature web framework suggestion (with good Kotlin interop)

Hi to all
I’m very new to Kotlin, but when I realised what my own code could look like in Kotlin, I immediately felt in love! :wink:

Maybe it’s a common question, but I can’t find exhaustive discussions on this: what’s the recommended web framework to use in companion with Kotlin (read better interop with Kotlin, and maturity)?
For example I never tried Grails, but a lot of people seem to find it one of the most productive framework. I imagine that trying to work with it in Kotlin rather than Groovy could be very hard, is it?

I don’t want to fiddle with immature frameworks though… And I usually prefer a separation between APIs to be consumed by mobile apps and third parties, and web applications (like B2B backends, and so on). But if there’s really a framework that can shine in both aspects, I can give it a try…

PS: please do not suggest Kara, looks promising but I’m not keen on writing everything (even views) with Kotlin… I think that HTML/CSS must be crafted by expert designers, that surely can’t deal with strange Kotlin based views…

Thanks to all!

1 Like

I don’t think there will be a recommended web framework since that’s all personal preference and needs. Some guys from Jetbrains are working hard on GitHub - ktorio/ktor: Framework for quickly creating connected applications in Kotlin with minimal effort. This isn’t mature yet but has a lot of potential.

So if you’re looking for maturity it’s the same for Kotlin as for Java. I do feel that any framework that’s code oriented (as apposed to annotation oriented) works better in modern languages like Kotlin. So for me Spring is no option, that feels old-fashioned. I’d rather use because I prefer the straightforward approach. It let’s you hook common template engines easily Documentation - Spark Framework: An expressive web framework for Kotlin and Java

1 Like

Thanks, these are definitely good points!

After reading the Spark homepage, I think I can agree with almost everything they say…

I’ve been exposed to Spring components lately, but not for web development. I forked the Apache Ftp (Mina based) project, and done a lot of work on it (that sooner or later I’ll contribute back somewhere).
They used Spring for configuring the various components, and it’s been the only pain point working on their codebase. I couldn’t do major refactoring on the config phase because that’d require a lot of work on the various config classes that deal with parsing the xml config file… I decided to configure my new components in code, and in the future rewrite the bootstrap code to get rid of Spring configuration classes!

But how something new like Spark compete with the completeness of the Spring ecosystem, or with other frameworks like Play?
When you need work done, and in a production-ready environment, you need a lot of components: Oauth/OpenId connect support, ACLs, remote logging, auditing, distributed transactions, real-time feeds, and the list goes on.

I agree with Spark folks, and I want a clear separation from pure API backends, and web applications that serve as management interfaces.

Regarding APIs, one thing that is often forgotten, is how much code you need to write for various client platforms (web, iOS, Android, Windows mobile, desktop apps).
I really hate Node.JS (for direct exposure), but something like is not easy to find elsewhere…

So, for my next project, I want to try using Kotlin (and the JVM in general) for writing the web administration part only, and see how it works in a micro-containers world.

I use docker and other services extensively, and I’m a bit concerned by JVM’s memory requirements. With other technologies I can spin up several containers with relatively small memory pressure on the host.
How can this be accomplished with the JVM, if a simple app could require a gig to boot up (disclaimer: read this on posts about frameworks like Grails or Play)?


1 Like

I suggest JAX-RS. It is not Kotlin specific but powerful and relatively simple. I consider frameworks like Spark to be overly simplistic. They don’t support even simple REST concepts like a ressource, as you can easily see when looking at code with repeated paths. JAX-RS makes simple things simple and complicated things possible. I suggest to use Jersey with an embedded Grizzly server. The setup is simple and requires about 5 lines of code.

1 Like

@medium Yeah, Jersey seems definitely a good choice for writing REST (ful/like) APIs, but as I said in my last post I’m looking for a web framework, in the more traditional sense. I mean I don’t bother if it includes support for writing APIs, as I’ll use another platform to write them, but I want a complete and robust platform for writing an MVC like application (AND want to be able to write in Kotlin :smile: )

You can use JAX-RS and specifically Jersey as an MVC framework. That JAX-RS has good support for RESTful design doesn’t mean that it is a poor framework for tradtional MVC usage. The REST principles don’t prohibit to render complete HTML pages … :wink:

@medium Well, didn’t know that! Thanks for pointing out :+1: I’ll look at it…

You could also have a look to Spring Boot which is much more easy to configure and use than legacy XML based Spring applications that you described, since Spring Boot has already good Kotlin support and plan to make it even better.

More details on Developing Spring Boot applications with Kotlin and A Geospatial Messenger with Kotlin, Spring Boot and PostgreSQL blog posts. To create a Spring Boot Kotlin project just go to!language=kotlin, select your build tool and dependencies, and generate your project archive.

(about your concerns about memory, the Geospatial Messenger sample app runs with Xmx=32M)

1 Like

@sebdeleuze Wow, that really looks promising! I recently made the switch to Postgres, and now my data tier really shines :wink:
I started reading your post on the Geospatial Messenger, and I can’t wait try all that stuff with my data model! Good one :+1:

Now I really need enough time to try coding something with Spark, Jersey, and Spring Boot, and see how they compare… Anyone got a DeLorean with a flux capacitor recently? :nerd:

Ditto. Old post I know, I’m catching up :stuck_out_tongue:

Using Spring Boot won’t really make the Spring components and the pain of configuring them go away, it will just hides those. I became in love with Vaadin since it makes JavaScript go away from me :slight_smile: If you’d like a full web stack Kotlin+Vaadin solution, maybe this may help? GitHub - mvysny/vaadin-on-kotlin: Writing full-stack statically-typed web apps on JVM at its simplest The documentation is certainly lacking, but it may be worth to invest some time and check out the example app.
This may be the clone of loopback you may be looking for: there is a web framework, a database support, REST, and no Spring nor JavaEE.
Disclaimer: I’m the author.

I think that the architecture of Vaadin has fundamental flaws.

What you expose on the server side is no clean API but a technical interface for the actual GUI part in the browser. You get for example events like “button x clicked” what doesn’t express any domain logic. One could argue that this would be only a technical detail of a GUI framework and that the actual interface would be the GUI itself. But then you have to test the GUI to be able to test business logic what is labor intensive and slow. And if you whish to support other clients than your Vaadin frontend you’d need to add an REST API anyway.

Compared to JavaScript framworks like AngularJS, React and the likes the round-trip times compiling a Vaadin project are slow.

Vaadin is based on server-side state what limits scalability and makes Vaadin unsuitable for microservice architectures.


If one is targeting microservices specifically, with the intent of exposing REST API, then Vaadin is probably not for you. On the other hand if you do not have to expose all of your data via REST, then Vaadin will save you lots of work since those technical APIs will automatically fetch and transfer the data for you. Also, the original question did not mention the microservices at all; @nexbit asked for a web framework in general, and in such case Vaadin qualifies.

Since it’s server-side framework as well, you can write and run business logic tests server-side.

Compiling GWT is slow, that is true. SuperDevMode can help, but as long as you are not writing custom components, you don’t need to compile GWT at all - it comes pre-compiled. Then, it’s just a matter of standard Java debugging and hot-redeployment.

Regarding the scalability: Vaadin can not compete with stateless microservices. It does hold its ground decently though: Vaadin Scalability . Of course, Vaadin was not designed to compete with microservices - it was designed to make the developer immensely productive.