Avoid bytecode

From Green software

Jump to: navigation, search

Byte-code is a form of instruction sets that is designed for execution by an interpreter (usually a virtual machine) as well as being suitable for further compilation into machine code. Programming languages that are translated to byte-code are called interpreted languages. Java and languages from the .NET framework are probably the most popular interpreted languages.

Contents

Advantage of byte-code

Once the interpreter is ported to a new system any program in bytecode should execute properly. This property has made especially the Java programming language very popular.

Drawbacks of byte-code

Because of the overhead introduced for interpretation by a virtual machine, byte-code is rather energy inefficient. Because of the interpretation needed for executing bytecode it can perform orders of magnitude slower than platform-specific equivalents. If the byte-code would all be compiled into machine code before execution, it would in theory perform equally well.

Unrealistic

Avoiding byte-code as a best practice for energy efficiency has been marked as unrealistic by all interviewees. The reason is that according to them the gain of portability by far outweighs the energy efficiency that is gained by using native languages. Writing a program in a native language and then porting it to other platforms can be much more expensive.

JIT Compiler

A Just-In-Time compiler (JIT Compiler), used in some systems, translates bytecode into machine languages at runtime. This runtime compilation is usually done for the most often executed code sequences. In the Java Virtual Machine, JIT compilation and interpretation are both used. Even though interpreted languages can not be executed as fast as compiled languages, but a JIT compiler can make up for a lot of this performance penalty. For interpreted languages, a JIT compiler can improve energy efficiency a lot.

See Also

Use low level programming

Sources

This best practices was recognized as such by IT professionals, described in Energy efficient software.

Personal tools