https://kotlinlang.org logo
#android
Title
# android
t

tjohnn

02/25/2020, 10:05 PM
What is the general opinion on using kotlinx.serialization on android in terms of size and methods count? Gson just does not do well with kotlin nullability.
And are there places where kotlin serialization is lacking compared to gson and moshi based on experience?
g

ghedeon

02/25/2020, 10:11 PM
iiric, no streams support for x-serialization yet and it's slightly slower. But overall positive experience
t

tjohnn

02/25/2020, 10:22 PM
Benchmarks show it is faster though, when last did you use it @ghedeon
j

jw

02/25/2020, 10:29 PM
Gson is long since abandonware. Any comparison should be against Moshi or Jackson.
t

tjohnn

02/25/2020, 10:39 PM
Thanks for the hint Jake.
c

Casey Brooks

02/25/2020, 10:48 PM
Unless you’re supporting really old versions of Android, you probably don’t need to worry about method count anymore, as Multidex is enabled by default since SDK 21. Total APK size is still something to keep an eye on, but there may be more important metrics, like runtime performance, and features. And kotlinx.serialization has pretty good runtime performance: faster than GSON, and slightly slower than Moshi. Feature-wise, kotlinx.serialization is newer and lighter-weight, but still does all I have needed from it. Personally, I prefer kotlinx.serialization mainly because of its multiplatform capabilities
👍 1
g

ghedeon

02/25/2020, 10:55 PM
@tjohnn using it daily but I'm happy with the experience enough, not to be bothered by the benchmarks. From what I remember from the recent kotlinconf it's not exactly faster. At the moment it's okay... which is promising, considering optimization wasn't a priority yet. It's good, go for it.
t

tjohnn

02/25/2020, 10:56 PM
Great explanations, thanks all.
2 Views