What are people's thoughts about ktor? <https://kt...
# server
u
What are people's thoughts about ktor? https://ktor.io/ What are the standard libraries people use for backend dev using Kotlin, it just Spring Boot? If there some good Kotlin backend open source libs that people can point me to, that would be much appreciated! Happy programming!
👍 2
f
Basically any framework that works in Java either works with Kotlin or has Kotlin specific stuff now (Dropwizard, Vert.x, Spring, etc), it really depends on what you need and what you might already be familiar with
j
You can take an eye to https://hexagonkt.com if you want to try a "Kotlin native" toolkit. It is a small library in the http://sparkjava.com spirit. Disclaimer, I'm the maintainer
1
👍 1
j
You could also take a look at https://micronaut.io/ it’s a relatively new framework but has some great Kotlin support so far and is continuing to grow! It also boasts some great start-up time and memory usage, along with some serverless & CLI support too
2
a
I've got a ktor back-end in prod from some months ago . . . at the time, it felt a bit premature. I want to try it again later, though! Issues at the time: • missing some support for specific OAuth2 workflows • Jackson middleware hard to consistently use & configure • DSL is good for simple use cases, but a difficult split of concerns for composition • docs a bit hard to navigate for non-simple cases That said, it stayed completely out of the way, not trying to reach its tentacles in everywhere (contrast with Spring*). The docs were great for getting started, too.
Every other Kotlin API I've done in SpringBoot (usually not given a choice :P)
x
@unnsse At work we use different stacks depending on a set of factor (team language and framework proficiency, project size, customer requirements, …).
Spring Boot
is usually the choice that make customers confident (you take no risk by choosing Spring), and doesn’t imply too much change for a team of java developers. But is has not been designed with Kotlin in mind. We have used
ktor
for some small projects, its strong support for coroutines makes it very efficient, but I personnaly agree with Andràs on the issues. We have also used
http4k
when I was given the choice. This is my personnal favorite, due to its very elegant design, pure Kotlin, and a large set of features. Plus the authors and community are very responsive on the slack channel.
❤️ 1
👍 1
j
👍 for
http4k
. Very happy with it, and slowly migrating a lot of older services to it. And you can shout at the authors in #http4k .
r
ktor ❤️
r
For web/http server micro frameworks, I like jooby a lot. Well designed, has a broad set of modules and has a kotlin version of the routing DSL. There is a 1.x and a 2.x line, the 2.x is already maturing and has coroutine support as well. Much less complex and loaded with legacy than spring boot, so you can keep stuff much much leaner and its not as framework-y forcing you into any other choices regarding architecture. Not even dependency injection is mandatory in any way. https://jooby.io
1
e
I like Ktor a lot, definitely feel like it could be used in all the same places where you’d normally use Node.js. There’s definitely a learning curve but once you wrap your head around the Ktor pipeline it’s super nice
But like others have said, there are other options that are more mature so you should consider them also
j
we've been happy using dropwizard, had lots of java experience with it already. we wrap it with guice+hocon config in a somewhat opinionated way that you can look at here: https://github.com/trib3/leakycauldron/ and can look at an example service here: https://github.com/trib3/example-cauldron-service
u
Thank you guys, I will explore all of these soon, love the community support that Kotlin has.
r
🎉also love http4k! its author is very nice. I once opened an issue for a stupid question about credentials lookup and security for route on route basis, he give me detailed explanations many times with an incredible small dely. but i have to say maybe the biggest problem is that the lack of community, like docs, and production experience. the official docs is about all practical docs you can googled, so if there're some cases that the official docs don't cover, it'll go for what I called somewhat _Slack-based programming_: I experienced this for kroto-plus, rho, and http4k, I'll say it's not very happy. But fortunately the developers of these libraries are all very, very kind, I think they love their project and are welcoming to questions. thanks them a lot.
a
I know this thread is already some days old, but I’m putting my 2 cents in here anyway. 🙂 We’ve been using Sparkjava for a year or so now and recently switched to [Javalin](http://javalin.io/) for new APIs. We also use it for non-API services to expose liveness/readiness probes, metrics and the like. Small libraries/frameworks seem to work better for us using Kotlin. We haven’t had too great of an experience with Spring, though. 😕
v
Quarkus is another cool and modern web framework for building fast-started and low memory printed microservices. quarkus.io https://quarkus.io/guides/kotlin
n
The fact that Quarkus requires using Maven ( https://quarkus.io/guides/kotlin#creating-the-maven-project ) will be a showstopper to many Kotliners that use Gradle. According to the 2018 Kotlin Census 80% of Kotliners use Gradle for Kotlin JVM based projects ( https://www.jetbrains.com/research/kotlin-census-2018/ ).
v
n
Wasn't very obvious in the article since the key information is hidden deep down towards the middle of the article.