A summary on the talks that happened in GDG SG X Kotlin User Group SG - Kotlin/Everywhere Meetup on 24 September 2019.
Talks:
Please shoutout to me or help to improve these notes by commenting below if you noted down something relevant that I missed out here! I am aware that some Q&A are missed out, and this is because I am not knowledgeable enough in Kotlin to understand what is being mentioned.
EDIT LOG
- 26/9/19: Saurabh Arora helped to make changes to the points for his talk!
 
Speech by Karen Ng from USA, Google
- Accelerate Android development by making high-quality apps easier
- with a modern, concise & expressive language
 - safer code and require less boilerplate
 
 - There used to be a lot of debate whether Kotlin would be added as a first-class language right before the Google I/O speech 2017
- In I/O 2019, Kotlin is also an official language inside Google and Android Development
 
 - As of 2019 Stats:
- 53% of professional developers are using Kotlin for Android
 - 32% using Kotlin as primary language
 - 50% of top 1000 apps on Play store are using Kotlin
 
 
Confirmed:
- Continue work on build speed
 - Kotline IDE Support
 - Annotation processor alternative
 
Embrace Kotlin-firs everywhere including Jetpack libraries. e.g. Android Jetpack v4.0, Jetpack Compose
Q. Google also developing on Flutter, so how about Android Jetpack Compose development in the future? A.
- Android supported languages: C++, Kotlin, Java
 - Jetpack compose actually partner with Flutter.
- Flutter has great and simple React APIs, so they want to make it that way also for the Android Jetpack Compose.
 - In the Android development ecosystem, Jetpack Compose still has a place since there might be developers who still need to develop specifically for Android
 
 
Speech by Saurabh Arora
- Primitives cannot have null value by default, so the compiler by default does not check if such variables are nullable.
- Unless you indicate the primitive as nullable, then the compiler will check for it intentionally, and this may result in autoboxing.
 
 - Lazy variable handling
- Accepts a parameter to do synchronization
 - Might also perform autoboxing for many variables if there are variables are declared to be possibly nullable
 - Any better way to optimize: By default, Thread safety mode is supposed to 
LazyThreadSafetyMode.NONEand notnull. So if you know for certain that function runs on a single thread then can pass it thread safety mode tonullto improve performance 
 - Arrays are mapped differently in Kotlin
- e.g. 
Array<Int>->Integer[] - e.g. 
IntArray->int[] 
 - e.g. 
 - If Java did not have any annotation, there might still be a chance for the Kotlin variables to be null
- If you are parsing API response and your Kotlin variable is defined as non-null, you can use a serialization library to assign it a default value to avoid it trying to store null
 
 
Side comments:
- Premature Optimizations is the root of all evil, but it does not mean that you don't do it, just be aware of what actually happens.
 - We should not sacrifice null safety to avoid autoboxing
 
Speech by Marcel Pinto Biescas.
Git Repo containing code for concepts discussed below will be uploaded by Marcel later, I'll post a link to it when it's done.
- 
The difference between
list.add(x)andlist.plus(x)pluscreates a new list after adding an element to the listaddonly adds an element to the list
 - 
The difference in initializing the variables by
var listandval listval list: cannot add element to the list if the variable is declared to be finalvar list: can add if make the list
 - 
Nullability Gotchas: Using
requireNotNull(x) {}andx!!on a nullable variable if the variable is applied as a variable to a function that does not accept nullable parameters.- Be careful of concatenation of many 
.run{} - There is a good graph that describes when to use a certain gotcha
 
 - Be careful of concatenation of many 
 - 
lateinit(::some.isInitialized)- if need many lateinit, should just declare it nullable
 
 - 
Overriding the
get()function of a variableget()takes priority over theoverridekeyword when applied to interface variables in classes.- use of 
init { }for initializing variables inside a class 
 
Still waiting for the invite...