What’s an intermediate language?

Print anything with Printful



When source code is compiled, an intermediate language is created which acts as a bridge between writing and executing the program. It allows for precise optimizations and portability. Some languages, like Java, use bytecode for optimization and portability. In some cases, an existing language can be used as an intermediate language, such as JavaScript for web applications.

In computer programming, when human-readable source code is parsed by a compiler, the compiler often translates the source commands into a sequence of instructions that are not really native machine code but can be further processed, optimized, or compiled by the compiler or from other software tools. The files that are produced contain instructions that are said to be in an intermediate language, because the language used by the compiler is not significant to the larger operating system nor the language used by the programmer to write the code in the first place, but instead is a language which acts as a bridge between writing and executing the program. An intermediate language is sometimes used to allow a compiler to make very precise optimizations so that the program runs more efficiently, but it can also be used to produce output files that are portable between different systems and incompatible. The actual syntax of the language may resemble machine code or other types of non-human readable bytecode, or the language may just be an existing cross-platform computer programming language.

When used for compiler optimization, a language compiler takes each instruction in a source code file and splits the command into the intermediate language. A single human-readable programming instruction can break into dozens of machine language instructions, so the intermediate language creates a layer of abstraction that the compiler can use to identify areas of the code where optimizations can be made without having to first map the code any native implementation or library. Once complete, the intermediate code file can be further compiled to create a native binary, or it can be run through another program, known as an interpreter, which will execute the code by compiling it into native instructions as needed.

Some languages, such as Java®, use an intermediate language to create compiled files that are optimized but also portable to other computer systems. This type of code is sometimes known as bytecode and resembles machine code or assembly language. Bytecode is stored in files in a platform-independent manner, which means it can be transferred to any computer system or device capable of running an interpreter. Once the bytecode is on a system, it can be run as an interpreted program or it can be compiled to run natively on the target system.

In some cases, a computer language is designed to simplify programming toward a specific end, such as an interactive Web application, but designers don’t want to include custom compilers, interpreters, or plug-ins for different systems. In these cases, the intermediate language of the compiler can be an existing language that already has established cross-platform interpreters. The resulting intermediate language in this case is human readable. An example of a computer programming language that is also used as an intermediate language is JavaScript®, which has the advantage of being able to run in almost any web browser on any platform, as of 2011.




Protect your devices with Threat Protection by NordVPN


Skip to content