Simply put, this is the procedure: smile: As a beginner, it was refreshing to say: thinking: What is compilation? ?? ?? It's like: sweat_smile:
I would like to explain what it is like little by little: smile: I think it's probably like this Please point out any misunderstandings: smile:
Many people know the source code, don't they? The following programs we create: smile:
Example.java
public class Main {
public static void main(String[] args) {
System.out.println("hello, world!");
}
}
Well, this program. Even if we write the code neatly, unfortunately the computer cannot understand it as it is: rolling_eyes:
Even if you talk to foreigners who don't understand Japanese in Japanese, they won't understand it: sweat_smile:
So what should I do ... I think it's easier to get an image if you anthropomorphize: smile:
It would be nice to have someone who understands each other's words come in and translate: laughing:
The equivalent of that interpreter is compilation: laughing:
This compilation has the feature of ** translating source code written by humans into machine language **.
: bulb: ** Compile features **: bulb: : sunny: Convert source files to class files : sunny: The converted class file contains what is called bytecode. : sunny: Compile uses software called a compiler to do the above work. : sunny: The compiler also checks the grammar of the source code
Converting a source file to a class file means File name.java → File name.class It means to convert the extension to.
The extension is .Txt for notes .Docx for Word .Xlsx for Excel .Pdf for PDF Etc., which is listed after the file name.
Let's get back to the story: smile:
And there is something called a bytecode in the one converted into a class file, but this ** bytecode is a complex array of 0s and 1s **. In other words, the source code we created is converted into the one formed by 0s and 1s.
file name | source file | Class file |
---|---|---|
The contents of the file | Source code | Bytecode |
If I change the source file to a class file, should I modify the file extension? : thinking:
I think that, but it will probably be an error.
What to do is to use software called a compiler. Compiler for compilation ... confusing: sweat_smile:
Well, this compiler. It also checks the grammar of the source code we create.
Hey, isn't the English spelling wrong? Hey, isn't it cool?
Etc. will be checked. By the way, it won't compile until I fix these. You will be sent back all the time: sweat_smile:
I had them translated into the words of the machine, and finally the program was executed! : fist: I think, but wait a minute! : hand_splayed :.
In fact, it still doesn't work at this rate. You can't do it because you converted it into machine language! ?? !! ?? I think. At least I thought: sweat_smile:
Compared to the source code, it looks like it can be executed, but it cannot be executed.
When I think about it again as anthropomorphic, the compilation uncle who translated it earlier. It's nice that he translated it, but the dialect was too tight to convey to the other party ... I think it's like: sweat_smile:
In that case, we need someone who can translate this compilation uncle's dialect into standard language. that is···
Interpreter: smile:
: bulb: ** Interpreter features **: bulb: : sunny: Request bytecode conversion and execution : sunny: Has a mechanism called JVM
The bytecode translated by the compilation uncle is converted into a machine language called machine code by the interpreter.
Send this translated machine code to the CPU for processing. (The CPU has the function of understanding the machine code in the brain part of the personal computer and executing and calculating instructions.)
** JVM is to have the CPU execute instructions while reading bytecode little by little. ** **
For example
Example.
Where is here?
How do I get to the station?
How long does it take to get to the station?
Suppose you ask the question. Then ...
Where is here? ↓ translation ↓ New York
How do I get to the station? ↓ translation ↓ Turn left at the next corner and stay straight
How long does it take to get to the station? ↓ translation ↓ It's about 10 minutes.
Does it feel like a simultaneous interpreter as an image? ?? Instead of listening to the other person's story and then translating it It's like interpreting while listening to the story.
Java programs are executed in this way: smile:
By the way, this interpreter is also one of the software along with the compiler. So you can't use Java without installing the compiler and interpreter.
Recommended Posts