Wikipedia:

bytecode

Bytecode is a binary representation of an executable program designed to be executed by a virtual machine rather than by dedicated hardware. Since it is processed by software, it is usually more abstract than machine code. Different parts of a program are often stored in separate files, similar to object modules.

Bytecode is called so because, historically, most instruction sets had one-byte opcodes, followed by zero or more parameters such as registers or memory address. It is a form of output code used by programming language implementations to reduce dependence on specific hardware (the same binary code can be executed across different platforms) and ease interpretation. After compiling to bytecode, the resulting output may be used as the input of a compiler targeting machine code, or executed directly on a virtual machine.

Compared to source code (intended to be human-readable), bytecodes are less abstract, more compact, and more computer-centric. For example, bytecodes encode the results of semantic analysis such as the scope of each variable access (that is, whether the variable is global or local). Thus, performance is usually better than interpretation of source code.

Execution

A bytecode program is normally executed by parsing the instructions one at a time. This kind of bytecode interpreter is very portable. Some systems, called dynamic translators, or "just-in-time" (JIT) compilers, translate bytecode into machine language as necessary at runtime: this makes the virtual machine unportable, but doesn't lose the portability of the bytecode itself. For example, Java and C# code is typically stored in bytecoded format, which is typically then JIT compiled to translate the bytecode to machine code before execution. This introduces a delay before a program is run, when bytecode is compiled to native machine code, but improves execution speed considerably compared to interpretation - normally by several times.

Because of its performance advantage, today many language implementations execute a program in two phases, first compiling the source code into bytecode, and then passing them to the virtual machine. Therefore, there are virtual machines for Java, Python, PHP[1], Forth, and Tcl. The current reference implementation of Perl and Ruby programming language instead resembles more that of an interpreter, since it works by walking the abstract syntax tree derived from the source code.

Examples

References

  1. ^ Although PHP opcodes are generated each time the program is launched, and are always interpreted and not Just-In-Time compiled

See also


 
 
 

Join the WikiAnswers Q&A community. Post a question or answer questions about "bytecode" at WikiAnswers.

 

Copyrights:

Wikipedia. This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Bytecode" Read more

Search for answers directly from your browser with the FREE Answers.com Toolbar!  
Click here to download now. 

Get Answers your way! Check out all our free tools and products.

On this page:   E-mail   print Print  Link  

 

Keep Reading

Mentioned In: