While in the search for the various differences in the meanings of source code, bytecode, assembly code, machine code, compilers, linkers, interpreters, assemblers and all the rest, I only got confused on the difference between bytcode and assembly code.
Particularly the introduction this wikipedia article to describe CIL confused me since it seems to use both terms (assembly code and bytecode) interchangeably making me think they might mean exactly the same.
Bytecode is something like an assembly language. It's not a real assembly language. The Java Virtual Machine then "runs" this fake assembly language, effectively translating it to a real assembly language.
Byte code is a non-runnable code generated after compilation of source code and it relies on an interpreter to get executed. Machine code is a set of instructions in machine language or in binary format and it is directly executed by CPU.
Both of these are codes that act as a set of instructions that help machines/ devices behave in a specified manner or perform certain operations/ tasks. The primary difference between byte code and machine code is that bytecode is an intermediate code while the machine code is the final code that the CPU processes.
Bytecode is kind of like assembly. And the JIT produces machine code (also like assembly). Neither is actually an assembler or assembly language. jvm input = bytecode (platform independent) , jvm output = binary code for target architecture.
Assembly code normally does mean the human readable form of a machine's native language (the so-called machine language). Byte code on the other hand is normally a language that can be interpreted by a byte code interpreter — so it is not the processor's native language.
Why the confusion then? You can't compare Assembly language versus Byte code this way. Of course a byte code can also have an assembly code — meaning a human readable form of it, because "Assembly language" does not necessary mean that it is for a real machine — but it is a human readable form of some native language — for processors, this native language is the machine code — but you also can have assembly code of a pseudo-(or interpreted) machine like Bytecode.
See also: Assembly Language
Further distress comes of course — like you can see in all the discussion here — because IT people (also myself) tend to be lax in wording. "Assembly language" is often used when speaking about machine code. This of course is not totally correct, because Assembly Language is only the human readable form of some machine's code.
I remember that since the begining of microcontrollers and microprocessors the word Assembly was used to designate the machine code in a human readable way. It seems to me that Microsoft has caused confusion by using the same word "Assembly" to name what would be the ByteCode produced by their dotNET Framework compilers. So in this case I'd say that what "Bytecode" means to the Java runtime is similar to what this new use of the word "Assembly" means for Microsoft dotNET runTime environment. Am I wrong to assume that?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With