Java Compilation and its Interpreter

How the computer reads instruction?

Every computer has a fixed set of instructions that it understands and the CPU (processor) will understand these sets of instructions. The program is made of sets of instructions. This allows us to write code to perform meaningful tasks where each instruction tells the CPU to perform certain actions as sequences of instruction.

Fetch-and-Execute Cycle

CPU executes the machine language using the fetch-and-execute Cycle. When the program is executed, the set of instructions are loaded into the memory. It then fetches the instructions and data to the CPU. The result after execution will be written back to the memory. This cycle continues until all instructions in the program are executed.

Compilation

It is very troublesome for humans to write instructions into 0s and 1s. Hence, engineers developed computer languages that help us to write instructions easier.

Interpreter

JVM - Java Virtual Machine

JVM is also called the abstract computing machine (This is why it is called virtual). It manipulates memory at runtime with automatic memory management and interpreting Java bytecode.

JIT Compilation - Dynamic Compilation

JIT Compilation in the execution engine inside JVM can identify which part of the Java bytecode that are frequently executed. It marks them as hot spots and saves the frequently compiled machine code into the Cache Machine Code which is saved in the memory for future use. Whenever in the future, if the corresponding code is executed, the cache machine code is then called for faster execution.

JDK - Java Development Kit

JDK refers to the Java SE Runtime Environment which used to run Java programs where Java SE (J2SE) refers to the Java Standard Edition, which defines the specification of Java, including Java Language Specification (JLS, define entire Java languages e.g. syntax), JVM Specification (bytecode definition) and Java API Specification (libraries).

Conclusion

It is a great start for reading this post before you get your hand dirty on Java from scratch or other programming languages. I have mentioned few important concepts included how computers execute what you write and how the Java program is executed behind. In addition, I have also talked about what are JDK, JVM, JRE Java SE, etc, important concepts. It is always good to understand these concepts to write or to learn java code in the future.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin Cheung

Kevin Cheung

𝑾𝒉𝒂𝒕 𝑰 𝒄𝒂𝒏𝒏𝒐𝒕 𝒄𝒓𝒆𝒂𝒕𝒆, 𝑰 𝒅𝒐 𝒏𝒐𝒕 𝒖𝒏𝒅𝒆𝒓𝒔𝒕𝒂𝒏𝒅. . An ordinary developer records his life and learning progress.