It is not a good thing for a Java programmer not to know how Java program, compiler and the interpreter works.
It is only in the past few years that many people started learning how to program that you see them understanding what a programmer is saying.
Unlike before where you hear a lot of questions when someone begins a discussion about programming.
Nevertheless, it is a beautiful thing for a Java programmer to know the basics of how the language works and should be able to explain it to a novice and the likes.
I have broken every little detail you need to know. So what are you waiting for?
What Is A Compiler/Interpreter
You need to know what high level or low-level language is in other to fully understand the meaning of a compiler or interpreter.
Most of the programming languages that you know are high-level language. These languages are written in English that you and I can understand.
Java, C++, and so on are high-level languages.
This the language that the computer understands. You must have heard the saying that computer only understands 0s and 1s. The low-level language is in 0s and 1s i.e binary.
You can imagine how difficult it will be if we have to give the computer instruction using binary. That is where a compiler or interpreter comes in.
Compiler and interpreter change the code written in a high-level language into low-level language for the computer to understand.
What Is The Difference Between A Compiler And An Interpreter
The interpreter takes in the source code written in high-level language, changes each statement of the code into the machine language equivalent and execute it line by line.
After executing the first statement, the compiler goes to the second statement until all the statements in the source code are executed.
The compiler takes in the source code and convert all the statements in it into machine code, all at once, and leave it for the executor to execute the machine code.
How Java Works
A Java developer writes java codes using either an IDE or other platforms. This code is known as Java source code and it will be saved with .java extension.
The source code will go through a compiler when the developer runs it. After compiling, the code will be converted into Java bytecode with a .class extension.
It is this bytecode that the Java Virtual Machine (JVM), an interpreter, will execute line after line.
How Is Java Platform Independent?
You can write a java code and run it on all platforms and Operating Systems, this is one of the beauties of the language.
How is that possible?
As you have known, JVM is the interpreter that runs a Java bytecode. So, different OSs have its own JVM.
The JVM that a windows computer will use is different from the JVM that a Mac computer will use but the two OS will run the same Java bytecode and give the same output.
Thanks for reading, I hope you learn one or two things from this post. Please share this page with your friends on social media 🙂