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!
Underlying == Okay?
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 price of simplicity
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.
Let’s talk about the standard library
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".
Not a postscript
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



C language data structure: The data representation of the tree and graph is a hierarchical data structure consisting of nodes. Each node contains a data element and a pointer to its child nodes. The binary tree is a special type of tree. Each node has at most two child nodes. The data represents structTreeNode{intdata;structTreeNode*left;structTreeNode*right;}; Operation creates a tree traversal tree (predecision, in-order, and later order) search tree insertion node deletes node graph is a collection of data structures, where elements are vertices, and they can be connected together through edges with right or unrighted data representing neighbors.

The truth about file operation problems: file opening failed: insufficient permissions, wrong paths, and file occupied. Data writing failed: the buffer is full, the file is not writable, and the disk space is insufficient. Other FAQs: slow file traversal, incorrect text file encoding, and binary file reading errors.

C language multithreading programming guide: Creating threads: Use the pthread_create() function to specify thread ID, properties, and thread functions. Thread synchronization: Prevent data competition through mutexes, semaphores, and conditional variables. Practical case: Use multi-threading to calculate the Fibonacci number, assign tasks to multiple threads and synchronize the results. Troubleshooting: Solve problems such as program crashes, thread stop responses, and performance bottlenecks.

How to output a countdown in C? Answer: Use loop statements. Steps: 1. Define the variable n and store the countdown number to output; 2. Use the while loop to continuously print n until n is less than 1; 3. In the loop body, print out the value of n; 4. At the end of the loop, subtract n by 1 to output the next smaller reciprocal.

Algorithms are the set of instructions to solve problems, and their execution speed and memory usage vary. In programming, many algorithms are based on data search and sorting. This article will introduce several data retrieval and sorting algorithms. Linear search assumes that there is an array [20,500,10,5,100,1,50] and needs to find the number 50. The linear search algorithm checks each element in the array one by one until the target value is found or the complete array is traversed. The algorithm flowchart is as follows: The pseudo-code for linear search is as follows: Check each element: If the target value is found: Return true Return false C language implementation: #include#includeintmain(void){i

C Language Data Structure: Overview of the Key Role of Data Structure in Artificial Intelligence In the field of artificial intelligence, data structures are crucial to processing large amounts of data. Data structures provide an effective way to organize and manage data, optimize algorithms and improve program efficiency. Common data structures Commonly used data structures in C language include: arrays: a set of consecutively stored data items with the same type. Structure: A data type that organizes different types of data together and gives them a name. Linked List: A linear data structure in which data items are connected together by pointers. Stack: Data structure that follows the last-in first-out (LIFO) principle. Queue: Data structure that follows the first-in first-out (FIFO) principle. Practical case: Adjacent table in graph theory is artificial intelligence

Troubleshooting Tips for C language processing files When processing files in C language, you may encounter various problems. The following are common problems and corresponding solutions: Problem 1: Cannot open the file code: FILE*fp=fopen("myfile.txt","r");if(fp==NULL){//File opening failed} Reason: File path error File does not exist without file read permission Solution: Check the file path to ensure that the file has check file permission problem 2: File reading failed code: charbuffer[100];size_tread_bytes=fread(buffer,1,siz

C language functions are reusable code blocks, receive parameters for processing, and return results. It is similar to the Swiss Army Knife, powerful and requires careful use. Functions include elements such as defining formats, parameters, return values, and function bodies. Advanced usage includes function pointers, recursive functions, and callback functions. Common errors are type mismatch and forgetting to declare prototypes. Debugging skills include printing variables and using a debugger. Performance optimization uses inline functions. Function design should follow the principle of single responsibility. Proficiency in C language functions can significantly improve programming efficiency and code quality.
