P
P
PetrJ2019-06-07 16:33:44
Kotlin
PetrJ, 2019-06-07 16:33:44

Is knowledge of Java Memory Model necessary for a Kotlin programmer?

I got interested in Android development, now I'm learning Kotlin, I came across an article about Java Memory Model https://ru.wikipedia.org/wiki/%D0%9C%D0%BE%D0%B4%D... - about the interaction of threads in multi-threaded programs.
How relevant is this information for a kotlin programmer for android? After all, Android already has its own ART virtual machine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrei, 2019-06-10
@umpteenthdev

When building an Android application, Java code is first compiled by a regular Java compiler into class files, and then converted into a DEX file using R8
( source 1 , source 2 )
Kotlin code also compiles to Java bytecode, because JVM language.
Therefore, if you write an Android application in Kotlin without thinking about JMM, then you can get Java bytecode that incorrectly describes your intentions, and it will be translated into incorrect Dalvik bytecode and the behavior will turn out to be appropriate.
In general, you need (in my opinion) to bother with the study of JMM .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question