Search code examples
jvmbytecodejitopcodepyc

Bytecode differences in different programming languages


I know several interpreted programming languages ​​(PHP, Python, Java, Smalltalk) are using Bytecode as an intermediate step to execute code.

Is there a difference between the form of Bytecode generated by different languages' interpreters​, as the differences between Assembly opcodes for different machines?

In addition, just to be sure, Bytecode can be used only in interpreted languages, right?


Solution

  • Bytecode is a generic word for the instructions executed by a virtual machine, in the same way that machine language is a generic term for the instructions executed by a real processor. Just as there are many different machine instruction sets, there are many different bytecode instruction sets. Some, like Java bytecode, are a documented part of a platform. All Java virtual machines execute exactly the same bytecode, by definition. Others are just an implementation detail, and differ from version to version.

    To answer your last question: no, that is not correct. Java is not an interpreted language; it is just-in-time compiled. C# is similar. Bytecode can be a part of many different architectures.