C Language Discovery Journey | Part One Lesson 1: What is programming?
Posted May 26, 2020 • 8 min read
- Openly defined
- What is programming?
- The first part of the second lesson
1 . Openly defined
I don't know why, I have always had a deep "feeling" for C language(similar to Lao Luo's kind of hammer phone).
- Maybe because the C language is a programming language that many seniors have taught that they must learn.
- Perhaps because the C language has been leading the way for decades since its birth in 1972, it is ranked in the top three of the programming language list;
- Maybe because almost all operating systems(Windows, Unix, Linux, macOS, Android, iOS, etc.), there are a lot of C language codes at the bottom;
- Maybe because C is the main programming language in the embedded field;
- Perhaps because in many programming languages, the entry of C language is more difficult;
- Maybe because it takes 5 to 10 years, you can say that you are proficient in C language;
- Maybe because you have learned the C language, you can easily get started with other languages.
There are too many possibilities, but what is certain is that C is a charming programming language.
The inventor of the C language, "Father of C Language" Dennis Ritchie died in 2011. Very low-key, there are not many news reports. In the same year Steve Jobs died, and reports from all walks of life were overwhelming(of course, Jobs is also a great person).
I want to say:I should commemorate those who pay a low profile.
In addition to the great invention of C language(Windows, Linux and macOS operating systems, C language is almost used in the bottom layer), Dennis Ritchie also developed the Unix operating system together with Ken Thompson(although most of the work was started by Ken Thompson, but later Dennis rewrote the Unix operating system with the C language he invented).
You should know that the Unix operating system has become the reference object of the world-famous Linux operating system. The bottom layer of the Android mobile phone is the modified Linux system. The bottom layer of Apple's macOS operating system is also a Unix-like system. The operating systems such as iPhone and iPad that we use are mostly written in C language.
Not only to improve the level of programming, but also to feel the demeanor of the master, and to explore the language we are in contact with every day, we must also learn the masterpiece of this great person:the C language.
In this system course, I will take you to explore the wonderful world of C language.
2 . What is programming?
You may have heard of programming, or maybe you want to really understand what programming is all about.
What about programming in C? Is it really good to use C as the first language for introductory programming? Can we do anything in C?
This lesson is to answer the above questions that may seem a bit stupid but actually very important. And through these questions, you will find the answer you really want after you finish this lesson.
Is n t it good to understand what you can do with it before learning the same technology?
We start with the simplest question:
What is programming?
Programming means "writing computer programs" that allow your machine(generally a computer) to do what you want it to do.
In fact, your computer is full of various programs:
- Calculator is a program;
- The text editor is also a program;
- Your chat software(QQ, WeChat, etc.) is also a program;
- The game you play is also a program.
The above picture may be a bit strange to everyone, but this is the classic game Metal Slug("Metal Slug" or "Vietnam War") that people of my generation(80s) like to play. It is a program.
Simply put, in today's daily life, programs are everywhere. As large as an aircraft carrier, space station; as small as a smart watch, iPhone, there are a variety of large and small programs.
The program allows you to do almost anything with a computer. You can write a revolutionary encryption software yourself, or you can write a 3D fighting game. Your computer can do anything for you(except making coffee, but it should be possible in the future).
Note, I am not asking everyone to write a 3D fighting game now, because it is too complicated and will make your fingers cramp. Our course will go step by step. It is the easiest at the beginning, and it may just be to display a piece of text in the window.
To put it bluntly, what is the C language?
Programming, what language?
Your computer(computer, also known as "computer") is really a strange guy, so to say it has given it a face. We pass commands to it and can only send it to 0 or 1(because there are countless transistors in the computer, and they are used as "switches", 0 and 1 can be used to mean "open" or " Closed "these two states, so the bottom layer of the computer is actually a binary code such as 0 and 1.) For example, I want to add the computer:
"Calculate how much 1 + 2 equals". What I actually lost to the computer(I wrote it casually, I do n t remember how to convert this sentence to binary code):
As you can see, this is the language your computer knows and is called "binary language". It also only speaks this language. It can be seen that this language is not easy to understand at all.
So, our first real question is here:
How can I use simpler language to talk to the computer, can it only use 0 and 1?
Your computer neither speaks Chinese nor English. However, even the craziest experts will not really want to write programs in binary code, which is simply unbearable.
Therefore, our computer scholars thought:write the program in other simple and easy-to-understand languages, and then translate it into the computer's binary language.
The most difficult thing is to write such a "translation" program. Fortunately, computer scholars have already written such a translation program, and we do not need to do it again(really relieved). So all we have to do is tell the computer:"I want to add:1 + 2 is equal to how much", this sentence will be translated into the computer's binary code:
I used simple words in the explanation above, but be aware that in the computer field, there are specific terms for everything. We will use proper terminology in this series of courses.
This is good, not only can it appear that you are "higher", but also when you have to explain some principles with another programmer one day, it is better to use professional terminology. Although the people around you might think of you as a "Martian", you don't have to ignore it.
As we said above, we can't write programs with 0 and 1, so we use "simplified language", which should be called "high-level language" in professional terms.
There are several levels of programming languages, the higher the level, the closer to our human language(such as English). High-level languages are easy to use, but they also have some shortcomings, as we will see later.
Here are some high-level languages:
- C ++
Of course, here are just a few of the commonly used ones. It takes a lot of time to list all the high-level languages.
In addition to the high-level language just now, another term we must remember is:source code. The so-called source code is the code you write in a high-level language. So you have to write the source code first, and then convert the source code into a binary code that the machine can understand.
Next, let's learn two terms:compiler and compiler. Compiler refers to a tool that converts source code into binary code that a computer can understand. This conversion process is called compilation.
There are different compilers for each high-level language. Of course, it is not difficult to understand, because each high-level language is different, we can not use the C language compiler to compile the source code of Java.
We will see later that even for a high-level language(such as C language), there are several different compilers, including Windows compilers, GNU compilers, and so on. We will learn these in the next lesson.
The binary program compiled by the compiler is called executable program. So for executable programs under Windows, there is a suffix of .exe(the first three letters of the English word EXEcutable, which means "executable").
Why choose to learn C language
As I said before, there are many high-level languages. Should we specifically choose one of them as the language of entry programming?
This is a big problem.
We have the following options:
- Very advanced language:very easy to use, can be said to be suitable for the general public. Among them, Python, Ruby, etc. Generally speaking, it is faster to write programs in these languages. However, they often require some additional files(such as an interpreter) to execute.
- Not so high-level language:this type of high-level language(C language is a kind), it is not easy to write. But learning such a language can help you understand the principles of programming and the principles of computer operation more deeply. It will be easy for you to learn a new language afterwards. You can learn by yourself.
In addition, the C language is very popular. A lot of the software we use every day is written in C language. Computer science also often uses C language as the language for teaching programming.
You may ask, I do n t understand one question:"What is the difference between C and C ++?"
It can be said that C language and C ++ are quite similar, both are very widely used languages. In order to better explain how they were born, let's talk about history:
In an era when computers weighed a few tons and were as large as a large room, the predecessors in the computer field began to invent a programming language:Algol.
With the continuous improvement of technology, they invented a new language:CPL, and later developed into BCPL, which was later called B language.
Later, it finally developed into C language.
After a while, people want to add something to the C language(some improvements, if you must say so). This new language was born, C ++, which was invented based on C language. C ++ adds a lot of new things on the basis of the C language, so that we can program in different ways.
Note:This is not to say that C ++ is better than C, but that it allows us to program in different ways. Nor does it mean that the C language is an old language compared to it, no, the C language is still very commonly used today. It is the basis of the operating systems we use such as Windows, macOS, Linux, Unix, and it is also the main in the embedded field. Programming language.
Is programming hard?
This problem may bother many people. Do I need to be a mathematician with several years of research experience to learn programming?
The answer is:never. Learning programming does not require much knowledge in mathematics. Of course, good mathematics is also beneficial to learning programming(such as writing 3D games, you need to have some knowledge of spatial geometry). In fact, the four most commonly used operations are:addition, subtraction, multiplication, and division.
What's so difficult about programming?
It is true that it is not so terrible. But you may need to know the mechanism of computer work, in order to better understand what we do in C language.
A programmer generally has the following characteristics:
- Patience:Many times, your program will not run smoothly for the first time, so be persistent.
- Logical awareness:There is no need to have a lot of mathematical knowledge, but you need to be able to think. Sorry for anyone who thinks programming is a breeze.
- Calm:You can't knock the computer with a hammer when you are impatient. For the program to run, it cannot be done.
Simply put, there are no skills that are particularly needed to learn programming. A person who has no knowledge of mathematics can also become a good programmer, the key is to have patience to think about the problem. Many people later discovered that they fell in love with programming and became fond of thinking.
3 . Summary
- In order to implement a computer program, we need to write the program in a language that the computer understands.
- There are many kinds of programming languages, and we can divide them by level. Generally speaking, the more advanced the language, the easier it is to master, but the final program performance may be worse.
- The C language we are going to learn together is considered to be a low-level one among high-level languages. It is the most famous and commonly used language in the world.
- The source code is a series of instructions, written in a programming language.
- A compiler is a program that converts our source code into binary code(0 and 1). The converted binary program can be executed by our computer. The .exe files that we often encounter in the Windows operating system are binary files, and there is no source code in them.
- Programming does not require very deep mathematical knowledge unless your program calls some mathematical formulas, such as encryption programs. However, programming requires you to be logically conscious and methodical.
4 . The first part of the second lesson
Today's class is here, come on!
I am , the public number "[Programmer League]( https://github.com/frogoscar/ProgrammerLeague/blob/master/qrcode . "jpg)" operator, elite lecturer Ms. Oscar , a lifelong learner.
Love life, like swimming and have a little understanding of cooking.
Life motto:"Go straight to the benchmark"