Byte Code Vs Machine Code

Posted by Tushar Bedekar
Generally, "machine code" refers to the data that can be executed by a certain computer, while "byte code" refers to data that can be executed by a virtual machine. The virtual machine takes the byte code and produces machine code appropriate for the actual machine it is running on.



Machine Code:-

Machine code or machine language is a set of instructions executed directly by a computer's central processing unit (CPU). Each instruction performs a very specific task, such as a load, a jump, or an ALU operation on a unit of data in a CPU register or memory. Every program directly executed by a CPU is made up of a series of such instructions.


Numerical machine code  may be regarded as the lowest-level representation of a compiled and/or assembled computer program or as a primitive and hardware-dependent programming language. While it is possible to write programs directly in numerical machine code, it is tedious and error prone to manage individual bits and calculate numerical addresses and constants manually. It is therefore rarely done today, except for situations that require extreme optimization or debugging.


Almost all practical programs today are written in higher-level languages or assembly language, and translated to executable machine code by a compiler and/or assembler and linker. Programs in interpreted languages[1] are not translated into machine code however, although their interpreter (which may be seen as an executor or processor) typically consists of directly executable machine code (generated from assembly and/or high level language source code).

Byte Code:-

Byte code, also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, byte codes are compact numeric codes, constants, and references (normally numeric addresses) which encode the result of parsing and semantic analysis of things like type, scope, and nesting depths of program objects. They therefore allow much better performance than direct interpretation of source code.

The name byte code stems from instruction sets which have one-byte op codes followed by optional parameters. Intermediate representations such as byte code may be output by programming language implementations to ease interpretation, or it may be used to reduce hardware and operating system dependence by allowing the same code to run on different platforms. Byte code may often be either directly executed on a virtual machine (i.e. interpreter), or it may be further compiled into machine code for better performance
.

Since byte code instructions are processed by software, they may be arbitrarily complex, but are nonetheless often akin to traditional hardware instructions; virtual stack machines are the most common, but virtual register machines have also been built.Different parts may often be stored in separate files, similar to object modules, but dynamically loaded during execution.


Source:-Wikipedia 

0 comments:

Post a Comment

back to top