What is a programming language? ||Introduction to computer hardware related to programming

What is a programming language?

Before learning a programming language, you must first understand the concept of "programming language".

When we were very young, our parents taught us to speak and how to understand what others said. After a long period of nurturing and self-study, we have learned to speak unconsciously, and at the same time, we can understand the meaning of other children's speech. We began to ask our parents for pocket money to buy snacks and toys, and confide in our parents when we were bullied. …

We speak Chinese, the "Chinese language". As long as we tell our parents what we want, they will be satisfied. We use the "Chinese language" to control our parents and let them do what we like.

"Chinese language" has a fixed format, and each Chinese character represents a different meaning. We must express it correctly so that our parents can understand what we mean. For example, if we ask our parents to give us 10 yuan pocket money, we will say "Mom give me 10 yuan, I want to buy a car". If we say "10 yuan for my car pocket money mom", or "Mom gives me 1 billion yuan, I want to buy an F-22", my mother will feel strange, do not understand what we mean, or misunderstand and blame us .

We control others through a "language" with a fixed format and a fixed vocabulary, making them do things for us. There are many languages, including Chinese, English, French, Korean, etc. Although their vocabulary and formats are different, they can achieve the same purpose. We can choose any language to control others.

Similarly, we can also control the computer through "language" and let the computer do things for us. Such a language is called a programming language (Programming Language).

Programming languages ​​also have a fixed format and vocabulary that we must learn to use in order to control computers.

There are many programming languages, commonly used are C language, C++, Java, C#, PHP, JavaScript, etc. Each language has its own advantages, such as:

  • C language and C++ are mainly used for PC software development, low-level development, single-chip and embedded systems;
  • Java and C# can be used not only to develop software, but also to develop website background programs;
  • PHP is mainly used to develop website background programs;
  • JavaScript is mainly responsible for the front-end work of the website (now some companies use Node.js to develop the background of the website).


Different programming languages ​​can be compared to the languages ​​of various countries. In order to express the same meaning, different sentences may be used. For example, to express "hello world":

  • Chinese: hello world;
  • English: Hello World
  • 英语:Hello everyone


In programming languages, the same operation may use different statements. For example, to display "C language Chinese website" on the screen:

  • C language: puts("C language Chinese website");
  • PHP: echo "C language Chinese website";
  • Java: System.out.println("C language Chinese website");


A programming language is similar to a human language, consisting of intuitive vocabulary, and we can easily understand its meaning. For example, in C language, we use the word puts to let the computer display text on the screen; puts is an output string (output character string) abbreviation.

Use puts to display "C language Chinese website" on the screen:

puts("C language Chinese website");

We put the content to be displayed between (" and "), and have a ; at the end. You have to write it like this, it's a fixed format.

Summary: A programming language is a series of instructions (Instruction) used to control a computer. It has a fixed format and vocabulary (different programming languages ​​have different formats and vocabulary), which must be followed, otherwise errors will occur and our goals will not be achieved. .

C language (C Language) is a kind of programming language, learning C language is mainly to learn its format and vocabulary. The following is a complete example of C language, which will make the computer display "C language Chinese website" on the screen.
This example mainly demonstrates some inherent formats and vocabulary of the C language. Readers who do not understand do not need to delve into it, nor do they need to ask why this is the case. We will gradually explain it to you later.

#include <stdio.h>
int main(){
    puts("C Language Chinese Network");
    return 0;
}

These words and sentences with specific meanings are organized together in a specific format to form the source code (Source Code) , also known as source code or code (Code) .

Then, the C language definitely specifies the meaning of each vocabulary and statement in the source code, and also specifies how they should be organized together. This is the syntax (Syntax). It is similar to what we call "grammar" when we learn English, and both stipulate how to organize specific vocabulary and sentences into understandable language.

The process of writing source code is called programming (Program) . A person who is engaged in programming is called a programmer (Programmer) . Programmers are also very humorous and like to laugh at themselves. They often say that their work is hard, their status is low, and they are like farmers, so they call themselves " code farmers ", that is, farmers who write codes. Some people mock themselves as " programmers ".

Introduction to computer hardware related to programming

No matter it is a desktop computer or a notebook computer, there is a circuit board inside, which is densely covered with electronic devices of different sizes, including CPU, memory stick, network card, various slots and interfaces, etc. This is the "motherboard". As shown below.

This picture mainly allows readers to understand the structure of the motherboard, and you don't have to understand the obscure terms in the picture.


 

Figure 1: Computer Motherboard

CPU

CPU (Central Processing Unit) is the "central processing unit", which is the brain of the computer, responsible for calculation, thinking, processing data, controlling other equipment, etc. Without the CPU, the computer is impossible to talk about. The speed of the CPU directly determines the operating speed of the computer. . As shown below:

Figure 2: CPU



At present, the common CPUs used in desktops and notebooks on the market are Intel (Intel) and AMD (Advanced Semiconductor Corporation). Intel has better performance and occupies most of the share.
The CPU has many pins, which are directly plugged into the motherboard, as shown in the figure below:

Figure 3: CPU socket

Memory

The memory is the rectangular "card" below, also called a memory stick.

Figure 4: Memory stick


We often say that a computer has several G of memory, which refers to its size. The common ones on the market are 2G, 4G, 8G, etc.
The C language program must be loaded into the memory to run, and the CPU is also designed to only read data and instructions from the memory. A programmer who does not understand memory is doomed to be unable to fully understand the operating principle of the program, and cannot let his programming level There is a qualitative leap.
Memory sticks are inserted into specific slots on the motherboard, as shown below are the memory slots of a desktop computer:

Figure 5: Desktop memory slots

However, in order to save space, the notebook usually lays the memory sticks flat, as shown below:

Figure 6: Laptop Memory Slots


There are generally multiple memory slots on the motherboard, and multiple memory sticks can be inserted. The size of the computer memory is the sum of the sizes of all the memory sticks. Memory sticks are also called main memory.

hard disk

Hard drives are used to store data. Open a file, and after editing, press Ctrl+S to save it to the hard disk, and it will not be lost when the power is turned off. Hard drives are divided into mechanical hard drives (HDD) and solid state drives (SSD).

A mechanical hard disk is like a VCD or DVD. A precision motor drives the disc to rotate quickly to allow the probe to read and write data. As shown below:

Figure 7: Mechanical hard disk


A solid-state drive is like a mobile phone memory card or a USB flash drive. There are hundreds of millions of electronic components inside, which are very small, reaching the nanometer level, and read and write data through circuits. As shown below:
 

Figure 8: SSD


Compared with mechanical hard drives, solid-state drives have great advantages in read and write speeds. An obvious example is that a computer installed with a solid-state drive starts up very quickly and rarely freezes.

The hard disk is not directly plugged into the motherboard, but connected to the motherboard through wires, so it is called external storage, which is also a part of the computer peripherals, but unlike the mouse, keyboard, U disk, etc., it can work normally without it. The hard disk is the normal operation of the computer. necessary external equipment.

coordination


Components such as the CPU, memory, and hard disk cannot fight independently. They are connected together through the motherboard, controlled by the CPU, and work in harmony.

Guess you like

Origin blog.csdn.net/m0_69824302/article/details/131408899