Hello everyone! We are about to build some new app...
# ktor
k
Hello everyone! We are about to build some new applications in our company to support external APIs. The first of them should be quite small and I was trying to convince people to use Ktor for it. We are already using Kotlin as a primary language even in our big monolithic app so I kind of sense that it would be better to use something more natural to Kotlin. I've been told that Ktor is a cool thing but not suitable for company like us, because people would have to have some initial knowledge about it and because Ktor is very small and lacks things like CDI so there are some strong opinions that we should stick with Spring Boot mainly because of our developer base. But I don't like Spring and the annotation-driven programming and all the magic.. Would you help me to collect some good arguments for using Ktor (+Exposed) instead of SpringBoot (+Hibernate)? I really think we have good oportunity for our devs to get in touch with it, but I need to convince them.. 😄
4
a
1. No annotations in ktor 2. Suspending by default 3. Architecture is un-opinionated
👍 1
k
@andylamax Thx for reply, could you elaborate a bit more on 3. ?
a
The docs would elaborate more than myself https://ktor.io/docs/structuring-applications.html
👍 1
k
It says in the first paragraph that it is flexible and it doesn't force us to use specific structuring pattern.. that doesn't sound "opinionated"
😁 1
a
Sorry, I meant to type. Unopinionated
✔️ 1
👌 1
m
here are some dev experiences, maybe you can use them as “cases”: https://nwillc.wordpress.com/2018/12/18/kotlin-microservice-spring-boot-to-ktor/ https://dzone.com/articles/not-only-spring-boot-a-review-of-alternatives The latter reviews some frameworks, not just Ktor, but highlights some points
k
@Matteo Mirk Thank you
m
IMO, if a developer has no prior experience with neither Spring nor Ktor, Ktor is way easier to learn. Usually, there is one obvious way to do things in Ktor but 5+ possible ways to do things in Spring, and Stackoverflow results from a few years can already be misleading in Spring, because they are outdated. One great feature of the non-annotation world ist that you can just “click” into the code that you are using, which helps understand the behavior way faster than reading docs. Regarding Hibernate vs Exposed, Hibernate is also a lot of under the hood magic, which one might like or not. Exposed gives you type safe queries and you can just write your own operators/types etc. (for example ILIKE or JSONB) pretty easily.
👍 4
j
By the way if you want a good introduction on how to build a web service with Ktor + Exposed + Postgres + some Ktor Features I'll be giving a talk at FOSDEM on the 7th of February
👌 1
k
@Julien Salvi can you share some link?
j
For sure after the conference 🙂 Also I am going to open source a sample project I made for the talk (it might be live this weekend if I have time)
l
@Julien Salvi I look forward to seeing 🙂
j
I also have an example at Github of how to develop Ktor APIs here: https://github.com/mathias21/KtorEasy And I’ve written some articles about Ktor @Medium: https://medium.com/@math21 I hope this helps. Let me know your thoughts
👍 1