Last Updated:

What is bytecode?

This term is used in computer literature quite often. It is also quite common in lengthy explanations of what the Microsoft .NET Framework is. However, what is really hidden behind this, at first glance, strange word, is not known to all users ...

To explain what exactly is bytecode, you need to explain how programs written in files on disk can be represented. Traditionally, they are written as sequences of instructions for the processor - operating codes that are transmitted by the operating system when executing a program directly to the processor.


There is another option - writing the program in the form of texts that are read by a special program (interpreter) and then already executed by it. There is also some intermediate option, when the program is written not in the form of text, but in the form of some code that is read and executed by the interpreter, but the code is not processor code in the full sense of the word. It is the last case of writing a program and is called a bytecode.


Typically, bytecode is machine-independent. What does this phrase mean? The fact is that the operating codes of the processor have a completely natural, but not very pleasant in some cases feature, which is that for each processor architecture its own operating codes are used.


In order for a program created for one processor architecture to run on another, it is necessary to retransmit it, i.e. create a version for the desired processor architecture. When using bytecode, this problem is solved automatically - of course, if we have our own interpreter for each processor architecture.


What is the advantage of bytecode over the way the interpreter works directly with the command text?

Well, first of all, we get the opportunity to hide this very text from prying eyes, which is very often absolutely necessary. Secondly, the program written with the help of bytecode takes, as a result, much less space on the hard disk. Thirdly, working with bytecode requires less memory from the computer and is faster than parsing the text of the program.

Working with bytecode, as I have already said, is the basis of modern Java and Microsoft .NET technologies, which allows you to use applications created on their basis on various software and hardware platforms.