DEV Community

loading...

Discussion on: Ktor - a Kotlin web framework

Collapse
jillesvangurp profile image
Jilles van Gurp

I agree ktor looks interesting. I'd be interested in using the native version of that when the native compiler comes out of beta. IMHO that makes perfect sense for small microservices that don't need a lot of cpu and memory.

BTW. Spring is going to be supporting co-routines from 5.2 and with stuff like Flow, a lot of the reactive stuff they currently push is going to look pretty dated. IMHO Spring is very good facilitating Kotlin developers but you do end up with a lot of legacy complexity. Ktor does not have that problem yet.

Compared to Spring, Kodein is pretty verbose. What I like with Spring is that simply slapping a few @Component annotations in the right places causes Spring to do it's thing. Mostly explicitly instantiating things or autowiring them is done implicitly these days. The constructor for Bar expects a Foo instance and there's a Foo class with @Component means that spring creates and injects the instance for you without needing to be told to.

Kodein is a step up from DYI dependency injection of course but not a big one since it requires more ceremony. Spring uses a reflection which is not available on native or the js platform to automate the bits that you have to spell out with Kodein.

Collapse
rjaros profile image
Robert Jaros

You can easily use Ktor with Guice. This way creating and injecting components is just as easy as with Spring.

Collapse
jillesvangurp profile image
Jilles van Gurp

Like Spring this works only on the JVM. A multi platform injection framework would be needed long term. If, I'm on the JVM, I'd probably prefer spring for dependency injection since it is less verbose.