Home >Backend Development >C#.Net Tutorial >C language is not simple, even programmers say so, why?
The first language I learned in college was C language. Everyone should be the same as me. Anyone who can use the language professionally should have learned C language. Maybe everyone agrees that C is the most basic and most basic language. It’s simple. Of course you have to learn it first. This is not the case. In fact, many programmers I know complain about how difficult it is to learn C. This is also true. Maybe the syntax of C language is very simple and suitable for beginners to start with. However, if it is used in development, it is extremely complicated. This article will introduce it in detail. apache php mysql
begin!
C language provides low-level operations, such as pointers. But the biggest difference between the C language and C is that the C language cannot avoid pointers, while C uses STL and smart pointer libraries to completely avoid it. In other words, pointers in other languages are just types, and pointers in C language are pointers. I have always believed that it is a taboo for beginners to come into contact with pointers too early. Beginners need to make fun applications that generate immediate feedback, rather than delving into computer systems that will only erode their confidence. Beginners should focus on the code logic and block out everything that deals with the underlying layer. Let’s use an analogy. If you were taught about the periodic law of elements and the VSEPR model when you were just learning chemistry, would you be interested?
Exposing the underlying layer is also harmful from another perspective, which involves manual management of memory in the heap. Computers are about a trade-off. You can say that this method has high execution efficiency, but in most cases, it is wrong to excessively pursue execution efficiency and ignore development efficiency. Manual memory management is a matter for senior programmers. Junior programmers should completely leave it to the features of the language to manage memory. Otherwise, if your program has a null pointer exception in three days and a memory leak in five days, who will suffer? Come on? Therefore, no matter from which point of view, C language is not suitable for getting started.
The editor recommends a place with a great learning atmosphere, C/C Communication Penguin Skirt: 341636727! It is suitable for college students and novices who want to change careers and find jobs through this program. There are a lot of learning materials in the skirt, masters answer communication questions, and there are free live broadcast courses every night
There is also a view that only the C language can access the stack and heap models . I am very responsible to tell you that all non-script compiled languages, such as c and swift, as well as managed languages, such as c# and java, can have access to the stack and heap model, and due to the automatic memory management mechanism , the latter uses the heap much more frequently than C. Scripting languages also have their own variable container models, such as PHP's zval. This blame should not be shouldered by programming languages, but by domestic junk textbooks. It can also be seen that the stack model of the C language is not universally applicable. If you apply it to other languages, it may not work. But some people insist on using it as the basis for learning other programming languages, which is really ridiculous.
The C language does not provide high-level encapsulation and abstraction of some common components. For example, when using a hash table, you have to build one yourself, or search online to see if there are any ready-made codes. This is very unfriendly to developers. Since there is no such thing in the C language standard library, it will not be mentioned at all when learning. This has led to many people not even knowing that such a thing exists, and they can only stare when they encounter problems. The only containers supported by C language are native arrays, and strings are implemented using native character arrays, so the processing of strings is very, very weak. If you want to write a code for string concatenation, it will take one line in Java and several lines in C language. This is the price of the "simplicity" of the C language.
The simplicity of C language is precisely the result of omitting the native support of OO. Why I mentioned native support above is because C language can still implement OO through combination. For example, inheritance is implemented through combination, virtual functions are implemented using pointer function members, and so on. In terms of OO, C language is much more difficult to implement than C. A keyword in C corresponds to a few lines of code in C language. How can it be said to be simple? Whether OO is good or bad, it is now a common language paradigm in the industry, and its role is just like English in natural language, playing a decisive role. If you don't get in touch with this, you will be at a disadvantage when looking for a job in the future. But is OO really complicated? If you read a Java book, you will spend at most two chapters introducing these things, one chapter is about classes and one chapter is about interfaces. Other languages that are not so OO just spend one chapter, just to tell you that there is a class, and this length is almost the same as the structure and enumeration in the C language tutorial.
The "simplicity" of C language means that in actual development, you need to do more manual operations instead of the compiler. I think God is fair. If he gives other languages more language features, he will also give them higher development efficiency.
The reason why the C language book is so short is not because there are no OO things, but the standard library It lacks some modern components, these things are all in posix. Talking about C language without posix api is just being a hooligan. There is no shortage of common components or facilities when it comes to the C language. Because of the modern program running environment and requirements, you can't write anything without these things. Of the five major libraries of modern programming languages (strings, containers, io, threads, and networks), the C language only misses two. As for the latter two, C language developers have to use posix api, and then solve the api incompatibility problem. The virtues of the C language standard library are half disabled without posix. And if you want to understand posix, you have to read "apue". If you tell me that C language is simple, tell me it is simple after reading the thick book "apue".
We learn a programming language not to prepare for exams, but to actually make things. A language like C that has no containers, no strings, no templates, no exceptions, no RAII, all the wheels are made by oneself, and has no features of modern programming languages, is extremely complicated to use. Sorry, I don't have time to study how every feature or class is implemented in C language. I still like to use shorter code to express my logic.
end:
#After reading this, you can see where is simple? Is it easy to write toy programs? Anyway, I think it looks very complicated, and it’s not like what it looked like when I was in college. Maybe I learned a fake C language at that time.
Related articles:
10 C language resources that will make you a better programmer
c language 10 A classic small program
Related videos:
The above is the detailed content of C language is not simple, even programmers say so, why?. For more information, please follow other related articles on the PHP Chinese website!