Hi folks, I'm reading about Dart's null safety and...
# announcements
s
Hi folks, I'm reading about Dart's null safety and based on their video, it says that Kotlin does not have this "Sound null safety". For what I understand reading the docs (https://dart.dev/null-safety) "Sound null safety" but looks like exactly what kotlin does when you are writing a full kotlin code, like a project that only uses others Kotlin libraries. Can someone clarify why kotlin is not "Sound null safety"? (image taken from

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

)
r
Probably because Kotlin uses runtime null checks.
j
Is this related with a old version of moshi library where you can declare properties as non null but if they are null you don't get the crash until you try to read them?
s
So the "problem" is in the Kotlin interop with other languages, but, in case I'm developing a project that uses only kotlin libraries, what the compiler does? They will still have runtime checks for my code? Other case is KMM, when we get to do a full application only from shared/common code, I guess this will happen in some close future, in this case, you will ONLY have libraries that are build in kotlin and all its types are already checked by the compiler, in this case it will still generate runtime checks?
t
Copy code
object Ouch {
    val world: String = { temp }()
    private val temp: String = "World"

    init {
        println("Hello ${world}")
    }
}
=>
Copy code
> Hello null
👍 3
e
Can anyone explain to me why above is not a bug?