What is the program?
What is the Program?
I would like to give an overview of the program.
A program is the most basic way to run a computer.
In a program, commonly referred to as a programming language, the
The computer is operated using a language for computers.
Without going to the trouble of explaining it here, most people will understand that programming languages are
We all know that it is a language for computers.
But still, it's not easy to understand the program because
This is because programming languages differ from natural languages in many ways.
The natural languages we humans use are called natural languages.
In other words, understanding the difference between programming languages and natural languages is the key to
This is the first hurdle in understanding programming.
In this chapter, the differences between the two languages are illustrated through specific examples.
The grammar of a programming language is simply the order in which words are written.
In this chapter, we will use a hypothetical programming language as our subject matter.
For example, look at the following example
This program means to project the word HELLO on the screen.
If we replace this program with a Japanese word, it would look like this.
This will mean that the word hello should be projected on the screen.
It is only two words, but this is the grammar of a programming language.
Most parts of speech used in programming languages are verbs and objects.
In the previous program, eise is the verb and hello is the object.
The verb comes first because computers were developed primarily in English-speaking countries.
The following is a translation of the previous program into natural language.
Comparing the two shows the simplicity of the syntax of the programming language.
|Project the word "Hello" on the screen.
|Programming language (Japanese words)
Those unfamiliar with programming languages may wonder at this simplicity.
However, as mentioned at the beginning of this section, programming languages are computer manipulation languages.
In other words, it is sufficient to express commands to the computer.
By the way, look at the program I just mentioned, even though the programming language says "project.
Some of you may have noticed that nowhere does it say "on the screen.
This is because "Eisei" already includes the meaning of "on the screen.
If it is necessary to express exactly where the image is to be projected, the following is used.
Project the screen. Hello.
With this writing style, you can change the object to which you move the hello.
Project it. Printer. Hello.
If you rewrite it like this, it will print to the printer this time.
That is not the only difference between programming languages and natural languages.
Second, programming languages have clearer meanings than natural languages.
There is absolutely no room for ambiguity; the meaning is strictly and unambiguously defined.
For example, consider the example of writing a triangle.
If we were dealing with humans, it would be enough to just say, "Draw a triangle.
When dealing with computers, the word "triangle" is too abstract.
Clearly, what are the steps and how to draw a triangle?
You must command a clear procedure with no ambiguity at all.
First, you have to order where to start writing.
The position of the point of entry must also be unambiguous.
If you want to specify a perfect location on the earth, you use latitude and longitude, but if you want to specify a perfect location on the earth, you use latitude and longitude.
In this case, a similar method is used, commanding from the upper left corner of the screen by a number of millimeters to the right and a number of millimeters to the bottom.
Once the initial writing position is determined, the next command is how far to draw the line.
If this position is made to form a triangle, then a triangle can be drawn.
The following is an example of how it is represented in the English programming language.
LINE 50,50 - 250,100
line 250,100 - 120,160
line 120,160 - 50,50
This can be translated into the Japanese programming language as follows.
Line 50,50 to 250,100
Line 250,100 to 120,160
Line 120,160 to 50,50
Furthermore, translated into ordinary Japanese, it looks like this
From the top left corner of the screen, 50 mm to the right and 50 mm to the bottom.
Draw a line 250 mm to the right and 100 mm to the bottom.
Draw a line from 250 mm to the right and 100 mm below the top left corner of the screen to a point 250 mm to the right and 100 mm below the bottom.
Draw a line 120 mm to the right and 160 mm to the bottom.
Draw a line from 120 mm to the right and 160 mm below the top left corner of the screen to a point 160 mm below the top right corner.
Draw a line 50 mm to the right and 50 mm to the bottom.
If you follow this procedure exactly, the following image will be written
Note that 1 mm is considered here as a single point.
It is a characteristic of programming languages to give commands in extremely clear-cut procedures like this.
There is no ambiguity in the procedure, and every action must be ordered in detail.
To give another example, if you want the computer to make you a cup of ramen
It is obviously not enough to simply say, "Make a cup of ramen.
One meter forward, turn 90 degrees to the right, stick your hand out 10 centimeters forward...
and on and on, until they take the ramen out, fill the kettle with water, light it on fire, and pour it in.
The human being must teach them every movement in detail.
Moreover, to a computer, these actions are just that: actions.
To a computer, every individual action is an independent action, not a
We do not recognize that, as a whole, it is the task of making a cup of ramen.
It just keeps moving as it is taught, that's all.
If, in the process of doing so, you happen to splash hot water from the kettle on the
It is just another action, and we do not perceive it as a mistake.
This alone seems very rigorous and unambiguous compared to our human counterparts, but
As a matter of fact, even the procedure described here is a procedure that remains ambiguous.
To begin with, drawing a line is a very ambiguous command.
You know that a computer screen is a collection of dots (called dots).
For each of these dots, you have to command which dot to draw.
If one were to give a perfectly clear command, such as
and the command, "Write a dot," must be repeated endlessly.
Going further, even "write a dot" is an ambiguous command.
If we were to express the command, "Write a dot," as a perfectly clear command, then
Set the 32050th number to 0.
This is a ridiculous order to say the least.
Let's consider a display with a width of 640 dots as an example, and use
Calculations show that the 32050th position is 50 from the top left of the screen and 50 from the bottom.
The OOth device is considered to be the display (or more precisely, the video card).
Note that "set to 0" refers to color, with 0 representing black.
Thus, broken down to the extreme, computer operation is
Determine if one number is 0. (Judgment)
Add two numbers together. (arithmetic operation)
*Furthermore, there are only four additions here: 0+0, 0+1, 1+0, and 1+1.
This means that there are only three
However, by combining these three, any complex calculation can be performed.
Today, a wide variety of functions have been created by our computer predecessors and
While we don't need to go into this much detail, we do need to consider the
Keep in mind that computers are such exacting machines.
Everything is calculated
The biggest difference between programming languages and natural languages is their purpose.
Third, programming languages are languages for computation.
In computers, numbers are everything, and there are no concepts other than numbers.
When we drew the triangles in the previous section, we specified everything numerically.
Similarly, everything dealt with in programming languages is numerical, and
After all, a programming language is a computational language.
However, as explained in the previous section, the only calculations a computer can perform are additions.
Of course, the additions can be combined to add, multiply, and divide, but
After all, that is the extent of the calculations that computers can perform.
A computer that can only add, multiply, and divide may seem inferior to a calculator.
Computers have the ability to perform calculations in the order specified by humans.
The language used to specify the order of calculations is a programming language.
Modern computers combine the order of addition, subtraction, multiplication, and division in tremendously complex ways.
Because of the intuitive mouse-operated functionality provided by the
Inevitably, the sense that we are dealing with numerical values is diminished.
However, when learning a programming language, a strong focus on numbers can help
It will be easier to understand the grammar, etc., which at first glance may seem difficult to comprehend.
About this Site
The C language (bitter C), which is learned by suffering, is
This is the definitive C language introductory site.
It systematically explains the basic functions of the C language and
It is as complete as or more complete than any book on the market.