Skip to content
Advertisement

would conversion from java code to jvm byte code considered compiling or transpiling?

Compiling is a process to conversion from one level of abstraction to lower level. Meanwhile transpiling is a process of conversion from one level of abstraction to another at same level like converting java code to Kotlin/python. That is my understanding of the two process. Could someone please explain it in terms of java code and jvm byte code. And is my inference correct?

Advertisement

Answer

Higher/Lower levels of abstraction from human language to machine language

A compiler translates from a higher level language to a lower level language. By higher/lower we mean how abstracted from machine language. So this would include Java language to bytecode. Bytecode is closer to machine language, and further away from human language.

A transpiler converts between languages of comparable levels of abstraction. Converting from EcmaScript 6 to EcmaScript 5 for compatibility with older web browsers would be one example. Converting from Java language to Kotlin would be another, or Swift to Kotlin.

See Wikipedia: https://en.wikipedia.org/wiki/Source-to-source_compiler

Intermediate representation

In particular, bytecode compiled from Java language and bitcode compiled via LLVM (from Swift, Rust, etc) are known as Intermediate Representation (IR). An IR is designed for further processing, optimizing, and translating on its way to becoming machine language.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement