Anyone here using Kotlin? We’re deciding which gen...
# general
h
Anyone here using Kotlin? We’re deciding which generator to use:
Copy code
jvm-ktor
Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).

jvm-okhttp4
[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.

jvm-spring-webclient
Platform: Java Virtual Machine. HTTP: Spring 5 (or 6 with useSpringBoot3 enabled) WebClient. JSON processing: Jackson.

jvm-spring-restclient
Platform: Java Virtual Machine. HTTP: Spring 6 RestClient. JSON processing: Jackson.

jvm-retrofit2
Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.

multiplatform
Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.

jvm-volley
Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9

jvm-vertx
Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.
g
@high-optician-2097 it depends on what framework for kotlin you are building on. if you are into the
spring
ecosystem,
jvm-spring-webclient
and jvm-
spring-restclient
would be recommended. Springboot recommends using
spring-webclient
.
Retrofit
uses
okhttp
in the hood only difference it is typesafe compared to okhttp.
Ktor
fits more into the kotlin ecosystem in the sense it uses coroutines. I've used
vertx
before but not sure i like it. Fits more into the eventloop threading model. For the rest, i have not used any of them. If it's simplicity,
okhttp4
, spring-webclient and retrofit2. Since it's kotlin android and pc, then
ktor
should be your choice.
h
What about multiplatform?
g
multi platform is basically a framework for sharing code cross platform like iOS and android . So not necessary a rest client. As you can see, it also uses Ktor as its rest client. If you want to share api client code across platforms, So if you are developing using the multi platform framework, then this should be the choice
h
ok i see, so not all apps are using the multi platform framework?
g
No. Only if you want to want a cross platform app that shares code between iOS and android
h
Ok I see, so it probably makes sense to publish multiple packages then?
g
Yes.
h
any recommendations on naming the package?
g
maybe you can shed more light on what you are trying to produce as an artifact. I could produce more information. but generally, what uniquely identifies the packages are the group id and the artifact id. the groups are basically inversed domains for example group could be
sh.ory
then the artifact could be prepended with the package that was built like
kratos-jvm-ktor-client
another option could be
sh.ory.<kratos|keto>
then the artifact could
jvm-volley-client
h
that's the info i was looking for! so i guess sh.ory.kotlin-multiplatform-client, sh.ory.kotlin-ktor-jvm-client would be an option?
can you use kotlin clients in java and vice versa?
g
Yes. They are options.
Yes for most of the clients. Kotlin and Java are jvm languages and so interoperable. The only clients that may not work correctly is kotlin clients that use Coroutines to handle async calls since they do not Java does not have the concept of coroutines. For the blocking methods, they should work fine.
h
ok great, thank you for all the help!
g
Sure. Anytime.