JR's Week1-2Jan2023 reading digest

Tan Jun Rong avatar

Tan Jun Rong

Here's a quick post of what I read this week!

Kotlin-Parcelize deep dive by Christophe Beyls

When we want to request an action from an app component in Android, such as Activitiy or Service, we have to use Intent. When we want to pass a non-primitive object through an Intent, we can either use the Serializable interface (Serializable doc) or the Parcelable interface (Parcelable doc).

The difference is that Serialize is a java interface, and it's using reflection to infer the serialization process while Parcelizable requires us to specify it (read). Luckily we have the kotlin-parcelize plugin provides us with the @Parcelize that will help to generate the code for us.

In this is a post 👇, Christophe Beyls took a deep dive to examine the generated code by the kotlin-parcelize plugin.

https://bladecoder.medium.com/a-study-of-the-parcelize-feature-from-kotlin-android-extensions-59a5adcd5909

How Upgrading to JDK17 for Android Development improves build time

Android runtime ART (previously Dalvik) runs its own bytecode (dex) which is different from standard JVM in Android. This causes the supported Java version in Android development to have always lagged behind the latest Java features. Now JDK17 has become LTS, we can upgrade it to gain the benefits of speeding up our build.

The blog posts below written by Oliver Falvai on Bitrise blog compares the build time of using JDK 11 vs JDK 17 on 3 open source Android Projects Tivi, Firefox Android, DuckDuckGo Android. The blog also examines the effect of different garbage collectors.

In this post, Inaki Villar measures the build for nowinandroid project using JDK11, JDK17 and JDK19:

Both authors are using https://github.com/gradle/gradle-profiler to measure their build.

Since we are talking about Java versions, the following serves as a bonus post to understand the versions!

Codegen with KSP, say goodbye to stubs (kapt)!

In the following video, David Rawson talks about why ksp is faster than kapt, and shows us how to use ksp to write a processor and how to generate code using codegen:

Kotlin's Reduce vs Fold

Chetan Gupta talks about the accumulator pattern reduce and fold in Kotlin:
https://chetangupta.net/reduce-fold/

Baseline Profile

This video talks about the evolution of code execution in Android from interpreted to JIT, then to Full AOT, then to Partial AOT and eventually with Cloud Profile and Baseline Profile.

https://www.youtube.com/watch?v=yJm5On5Gp4c

Jetpack Compose How Tos

  1. Philipp Lackner talks about how to use onTextLayout of Text to create an auto resizing Text, with the help of Modifier.drawWithContent.

https://www.youtube.com/watch?v=ntlyrFw0F9U

  1. He also showed us how to create a Shimmer effect using composed and rememberInfiniteTransition with Brush.linearGradient:

https://www.youtube.com/watch?v=NyO99OJPPec

  1. Another video talking about custom Modifier using composed:

https://www.youtube.com/watch?v=QeE_3c_56eM&t=539s

Tan Jun Rong avatar
Written By

Tan Jun Rong

Android Programmer who likes writing blogs, reading, coffee, snowboarding.
Enjoyed the post?

Clap to support the author, help others find it, and make your opinion count.