Hello! I've got weird but interesting for me ques...
# ktor
k
Hello! I've got weird but interesting for me question about ktor client library. Would be glad to hear developers team answers. Had you thought about giving some additional API besides coroutines one? If had but decided not to do it, then why? (I don't need different API, just want to understand your position in this question) Thank you! Looking forward for your answer.
e
Hey @Kamo Spertsyan, thanks for the question.
Could you give me an example of what API you expect?
a
maybe a callback based api instead?
k
Yes, callback based one
e
No, I'm sorry. We don't have any plans about callback based API
k
Could you explain a bit your position please?
e
Sure. Ktor client is made in a way that you can replace any blocking client without much effort: you don't have to restructure lots of code with callbacks and keep the logic linear. In the same time it's backed by coroutines, it allows to make implementation asynchronous.
I still not sure that I understand the question right: It's not clear for me what is a benefit of using callbacks instead of linear logic
k
I'm exploring different libraries with asynchronous api, so I'm just interested in the way you design ktor library. Coroutines API is not a problem) One last question please, want to clarify if I've correctly understood library. Are users able to use ktor without using coroutines in their projects?
a
Sorry for hijacking the thread. But IMHO, there is too much benefit of using linear logic vs callbacks. But for some platforms (Kotlin/JS), the cost of linear logic is so high that would make me settle with a callback based API for my multiplatform projects
e
@Kamo Spertsyan, nope there is no way
k
But for some platforms (Kotlin/JS), the cost of linear logic is so high that would make me settle with a callback based API for my multiplatform projects
And you build your own proxy with callback api over the coroutine-based libraries like ktor, right?
@e5l, okay, thank you very much for your answers!
e
@anton.bannykh @Kamo Spertsyan please get in touch to discuss this
No problem! Thanks for the good question
a
And you build your own proxy with callback api over the coroutine-based libraries like ktor, right?
Not really, just have a pure callback based on common code, and have something like suspending await methods, which one can opt to use over the default suspending ones. So, ktor-client-core becomes purely callback based, not depending on coroutines at all, and have something like ktor-client-ktx wich depends on coroutines and has those methods. Makes it easy to write common code independent of coroutines and use it in optionally in platforms like kotlin/jvm or kotlin/native
🙏 1
👍 1
a
@andylamax are you avoiding coroutine-based API due to increased code size, or performance considerations?
a
@anton.bannykh affirmative
a
@andylamax So both then? Could you share any numbers?
a
Let me work on the numbers, I will share them by the end of the day
🙏 1
🙏 1
a
@andylamax friendly ping 😃