Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Kotlin Serializable vs Java Serializable , is the performance the same?

I have read everywhere that Java Serializable is much slower than Parcelable . Is it the same case for Kotlin Serializable? Or is Kotlin Serializable equally fast as Kotlin Parcelable? Using Serializable seems to much simpler and i wanted to know if in Kotlin its fine to use Serializable instead of Parcelable.

like image 240
Dishonered Avatar asked Mar 08 '26 14:03

Dishonered


1 Answers

Kotlin standard library doesn't have its own definition of Serializable, if you have code using it you'll notice import java.io.Serializable. So it's exactly as fast.

There is @Serializable from kotlinx.serialization (thanks to Marko Topolnik for reminding me of it), but it works very differently and is not easier to use than @Parcelize (see below).

Using Serializable seems to much simpler

But here you have an advantage: in Kotlin it's just as easy, just use the @Parcelize annotation (see the design document as well).

like image 66
Alexey Romanov Avatar answered Mar 10 '26 02:03

Alexey Romanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!