"In the previous section, we casually said that the program would run,"
Here, I will explain this in more detail.
"Actually, the program you all described earlier is just a regular string."
You've probably heard that computers operate on
binary as well, have you?
Why can computers operating in binary recognize and process strings?
Originally, computers can only understand instructions written in binary code.
Instructions written in binary, what is commonly referred to as machine code.
000101001101010100101010
000101010101010010110100
101010001010101101010110
000101001010101001001101
000101001010101000000101
This is just a random string of zeros and ones, but it captures the idea.
No matter what computer, east or west, it can only recognize commands in this format.
Only machine code can be understood by computers.
In fact, programs like this were used in the early days of computing.
I was rapidly toggling a switch, inputting a massive amount of zeros and ones.
However, this is getting disheartening, no matter how you look at it.
So, the first thing that was considered was reducing the number of digits.
01 85 AD 7F 7C A4 FA 6B AD
06 F5 AB 74 7E DC 18 FA A4
01 7F A7 C5 D8 6B 4E A4 FA
This is what is known as a
hexadecimal representation.
Binary numbers require 4 digits to represent a value that can be expressed in one digit in hexadecimal.
And assemblers were also conceived that could
symbolize each of these numbers individually.
MOV AH,BH
ADD AX,70
JPN AF,01
This tokenization has significantly improved programming efficiency, but...
It remains a symbol that is still difficult for ordinary people to understand.
The first programming language to significantly change the world was FORTRAN.
DO 10 I=1,10000
READ *,X
IF (X,GT,MAX)MAX=X
10 CONTINUEA
At this point, it's become quite close to English sentences and equations, and anyone can understand it with a bit of study.
C is also counted among high-level languages, those closer to human languages.
【High-level language】
人間にわかりやすく書くことができるprogramming言語。
これに対して、マシン語やアセンブリを低級言語と呼ぶ。
Nuance languages are human-created, and therefore, computers cannot understand them.
A translation is necessary to make this understandable to a computer.
It's essentially the same as translating Japanese into English.
While this task could certainly be done manually by humans,
"So, in the end, it's not much different from programming in machine code."
Therefore, there is software available to facilitate translation.
There are mainly two translation methods, but for C, we use the method of translating everything at once.
C Language以外の言語の中には、Simultaneous interpretationを行うタイプもあります。
それらはインタプリタと呼ばれており、
It can be configured flexibly, but its disadvantage is slow speed.
There are also interpreted environments available for the C language.
プログラムを一つ一つ確認しながらrunでき、
バグ修正には大変便利なのですが、
C Language最大の利点である速度が犠牲になるため、
It will never be used for practical purposes.
We call the software that performs this translation a
compiler.
"Although I've already explained how to obtain and use the compiler, this software is what you need for that."
【Compiler】
A software that translates C language-written string files into machine code.
This compiler actually operates with a
three-stage process.
First, a software called a preprocessor adjusts the strings.
It refines the program by handling issues like combining whitespace and line breaks, and replacing symbols, to make it easier to analyze.
Furthermore, the #define pseudo-command, described later, is also processed here.
Next, it's compiled by the compiler, and during that process,
optimization takes place.
Even with the same C program, the execution speed can vary depending on the translation method.
The compiler is translating to optimize for speed.
【Optimization】
A feature that translates code into machine language optimized for faster execution.
Finally, this translated machine code program will be linked by a linker.
Combining with a linker is called linking.
By being linked, machine code data becomes an executable file.
C Languageのプログラム(Source code)
V
プリプロセス(文字列のadjustment)
V
コンパイル(翻訳)
V
リンク(結合)
V
run可能なソフトウェア(run可能File)
Sometimes, preprocessing, compiling, and linking are collectively referred to as compiling.
It's also common to refer to the creation of executable files as part of the build process.
The file, now an executable (essentially an EXE file),
It can be run as an application.
These tasks are now fully automated.
We often take for granted that software can be created that simply works with the press of a button.