1

I am writing code in Kotlin language. Recently I have realized that JVM interprets kotlin bytecode, the way it does with Java bytecode. So I read about differences between Kotlin and Java.

But, I could not understand the difference between bytecode generated by Kotlin compiler and Java compiler. Are they the same byte code at the end?

3
  • 1
    wiki says: Kotlin mainly targets the JVM, but also compiles to JavaScript or native code Commented Jun 26, 2020 at 3:16
  • stackoverflow.com/questions/2812564/…). Commented Jun 26, 2020 at 3:18
  • 1
    @beastlyCoder What does that Q&A have to do with Kotlin? Commented Jun 26, 2020 at 4:10

2 Answers 2

8

Kotlin compiles to Java bytecode, just like Java code, and is executed at runtime by the Java Virtual Machine. The JVM itself doesn't know the difference—it receives and executes bytecode in the same way, regardless of whether it was produced from Java or Kotlin

Sign up to request clarification or add additional context in comments.

Comments

4

I think there is no difference between Kotlin byte code and Java byte code.. Java compiler compiles .Java file to .class file... Similarly, Kotlin compiler compiles .kt file to .class file.. So I think they are the same... You can even decompile the java class generated by Kotlin compiler to the corresponding java file...

My answer is:- Yes, they are the same...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.