Which is a better choice for kotlin, quarkus or mi...
# server
i
Which is a better choice for kotlin, quarkus or micronaut?
ktor 11
I'm leaning towards quarkus
👍 1
c
depending on your exact needs you could also try vertx directly instead of quarkus
a
Vertx and/or javalin
Unless you specifically want springboot annotation style code
r
I really enjoy Quarkus, it's maintained by some really smart people and has regular updates.
1
That said, using Kotlin — especially with Coroutines — is still kinda awkward. It's continuously improving, but you will probably encounter some issues. If you need something simple you can use Vertx directly which has less stuff to potentially go wrong, however, many of the basic things Quarkus does like .env loading, live reloading, etc. are all really nice to have. https://vertx.io/docs/#kotlin
d
There's always #ktor (like the imoji...), #hoplite for configs, kotlin inject for DI, and theres other tools more kotlinish to replace other micronaut or quarkus features
c
don’t use a framework for DI in a web app. thats maybe useful in an android app where you constantly create new components. a web up should be wired up at startup via manual constructor calls and thats it IMO
4
😶 1
r
For what it's worth, both Quarkus and Micronaut (I think) resolve DI at compile time, so what you end up with is effectively a bunch of manual constructor calls.
p
Or jooby, or ktor
a
Or Spring Boot 🤷
🤨 2
c
just be aware that you give up a lot of kotlin niceties like immutability when you use a java framework that just has kotlin support like spring boot, quarkus or micronaut instead of a real kotlin framework. In all projects that I am involved with i always advise against it.
🤨 1
a
@christophsturm could you elaborate more specifically on this? Kotlin immutability doesn't vanish if you use Java framework or a library. In the application code boundaries, you're still exposed to Kotlin features including immutability and null-safety. Did you mean the fact that Spring requires the classes to be not-final to generate proxies?
p
@christophsturm I'd created two enterprise-grade projects in Spring and Kotlin, one of them even before 1.0 was released. We (my team and I) used all the nice things including data classes and read-only lists.
c
I think that if you have to offer a java api and a kotlin api you cannot offer a perfect kotlin api. I get to read a lot of spring boot code and I see mutability all over the place.
maybe I have yet to see a really well designed non trivial kotlin spring app, so if you have any pointers I’m always open to learning something new.
p
Yes, speaking of final-by-default we decided not to use plugins, but write "open" explicitly, but if you opt into using the plugin — you won't even notice this. And of course nothings can stop you from using data classes (if we're not talking JPA or smth like that)
a
That might be true to some extent. What I see is that Spring developers did a great job providing the extensions for Kotlin setting an example of how a Java framework can fit Kotlin devs
p
Everything mine is closed source of course and is owned by obsure russian banks
c
yes spring boot is impressive, so much well tested code for every use case you can think of. sadly hidden behind a wall of annotations and mutability.
🤮 1
p
Wait, where is the mutability is Spring? I'm not sure I mutated anything but my own object in 10 years of writing in Spring. And with Kotlin I stopped mutating my objects too
c
ok a lot of the mutability comes probably from projects that migrate from java-spring to kotlin-spring and from ORMs
a
yeah, ORMs is a bit different league
👍 1
p
Yes, ORMs are tricky, but they're not Spring. I use jOOQ and it doesn't need objects to be mutable for example (and it's not an ORM)
👍 1
But it's unfair to say Spring=ORM
a
Hehe 🙂 Spring + JdbcTemplate = My ❤️
c
still you could say that the heavy annotation use of spring, quarkus and micronaut is not very kotlinesque
and even if that werent true i would still not like it because its just not possible to find out what code handles an annotation so its very hard to understand code that relies so heavily on anntotations
a
yep, that's true! However, in Spring you can almost get away from annotations new with kotlin by using the various dsl extensions
c
oh great. I saw some prototypes for that but it said its postponed because graalvm support is more important
a
That's the Spring-Fu, yes, that's postponed. But even in standard spring, you can use BeanDefinitionDsl, for instance. I searched for *Dsl in the source code recently and there are tenth of classes in the framework for this. Hopefully, I will be covering those in the following episodes of Spring Time in Kotlin on our YT channel
p
Well, until there is no a nice alternative for aop in Kotlin, annotations will exist. I hoped that context receivers will replace them, but no :(
a
here's an example. Yes, there are still some annotations in use, but it's almost entirely DSL-ish: https://github.com/hantsy/spring-kotlin-dsl-sample/blob/master/webmvc/src/main/kotlin/com/example/demo/DemoApplication.kt
c
that looks nice. is it also possible to use spring without the spring boot annotation? I’m mostly interested in how to test my components and I don’t want to have to use a custom test runner or special test annotations.
a
I believe that one is part of Spring-Fu and isn't currently available in the standard Spring package. But we can hope 🙂
835 Views