Byte-code

From Free net encyclopedia

Byte-code is a sort of intermediate code that is more abstract than machine code. It is often treated as a binary file containing an executable program much like an object module, which is a binary file containing a machine code produced by compilers.

Byte-code is called so because usually each opcode is one byte in length but the length of instruction code varies. Each instruction has one byte operation code from 0 to 255 (or as hexadecimal: 00 to FF) followed by parameters such as registers or memory address. This is a typical case, but the specification of bytecode largely varies in language.

As in intermediate code, it is a form of output code used by programming language implementers to reduce dependence on specific hardware and ease interpretation.

Less commonly, bytecode is used as an intermediate code of a compiler. Some systems, called dynamic translators, or "just-in-time" compilers, translate bytecode into machine language immediately prior to runtime to improve execution speed.

A byte-code program is normally interpreted by a byte-code interpreter (usually called virtual machine since it is like a computer machine). The advantage is portability, that is, the same binary code can be executed across different platforms or architectures. This is the same advantage as that of interpreted languages. However, because bytecode is usually less abstract, more compact, and more computer-centric than program code that is intended for human modification, the performance is usually better than mere interpretation. Because of its performance advantage, today many interpreted languages are actually compiled into bytecode once then executed by bytecode interpreter. Such languages include Perl, PHP, Python, Forth and Tcl (Tool Command Language). Java code is typically transmitted as bytecode to a receiving machine, which then uses a JIT compiler to translate the bytecode to machine code before execution. The current reference implementation of the Ruby programming language does not use bytecode, however it relies on tree-like structures which resemble intermediate representations used in compilers.

Also of interest are p-Codes, which are just like byte codes, but may be physically larger than a single byte and may vary in size (much like opcodes on many CPUs). They work at very high levels, such as "print this string" and "clear the screen". Many versions of BASIC and some versions of Pascal use p-Codes.

Examples

es:Bytecode fr:Bytecode it:Bytecode nl:Bytecode ja:バイトコード pl:Kod bajtowy pt:Bytecode ru:Байт-код fi:Tavukoodi