Machine code vs. Byte code vs. Object code vs. Source code vs. Assembly code vs. Executable code

Machine code vs. Byte code vs. Object code vs. Source code vs. Assembly code vs. Executable code

Image for post

1. Source Code

  • Input to a compiler or other code translator. Source code is normally generated by humans (and thus hopefully able to be read and modified by humans) and is the human-readable representation from which all the other forms of code are created.

2. Assembly Code

  • is plain-text and (somewhat) human read-able source code that mostly has a direct 1:1 analog with machine instructions. i.e. a low-level programming language code that requires software called an assembler to convert it into machine code. hence it has strong correspondence between the program?s statements and the architecture?s machine code instructions. It consists of a set of English like standard instructions.

3. Object code

  • Object code is code generated by a compiler or other translator, consisting of machine code, byte code, or possibly both, combined with additional metadata that will enable a linker, loader, or linker-loader to assemble it with other object code modules into executable machine code or byte code. i.e. Object code is a portion of machine code that hasn?t yet been linked into a complete program. It?s the machine code for one particular library or module that will make up the completed product. It may also contain placeholders or offsets not found in the machine code of a completed program. The linker will use these placeholders and offsets to connect everything together.
  • Traditionally, a translator that translates source code represented in assembly language is called an ?assembler? rather than a compiler, but the same function is being performed. Note that some compilers generate output that is not object code: a compiler might instead translate its input into an intermediate language (such as LLVM IR) or even into a different source code language: many compilers emit code in C, and there are also many compilers that can generate output code in Javascript.

4. Byte code

  • Byte code (in Java, Python and etc.) is an intermediate code between source code and machine code that is executed by an interpreter such as JVM. e.g., Java class file. This makes byte code portable across multiple platforms (a combination of hardware and operating system) as long as a virtual machine is implemented on that platform. Instruction in an intermediate form which can be executed by an interpreter such as JVM. e.g., Java class file

5. Machine code

  • Machine code is binary (1?s and 0?s) code that can be directly executable by the computer?s physical processor without further translation.

6. Executable file

The product of the linking process. They are machine code which can be directly executed by the CPU. e.g., a .exe file.

7. Library file

Some code is compiled into this form for different reasons such as re-usability and later used by executable files.

Image for poststep by step behind the scene execution of C programImage for postbehind the scene execution in Java

similar to java python is also converted as follow:

Image for postbehind the scene execution in python

Conclusion: –

Building a complete program involves writing source code for the program in high-level language e.g. C++. The source code is assembled (for assembly code) or compiled (for higher-level languages) to object code, and individual modules are linked together to become the machine code for the final program. In the case of very simple programs, the linking step may not be needed. In other cases, such as with an IDE (integrated development environment) the linker and compiler may be invoked together.

There are also interpreted languages that behave differently. Interpreted languages rely on the machine code of a special interpreter program. At the basic level, an interpreter parses the source code and immediately converts the commands to new machine code and executes them. Modern interpreters, sometimes also called a runtime-environment or virtual machine, are much more complicated: evaluating whole sections of source code at a time, caching and optimizing where possible, and handling complex memory management tasks. An interpreted language may also be pre-compiled to a lower-level intermediate language or bytecode, similar to assembly code.

No Responses

Write a response