My point on C and C ++

Source: Internet
Author: User

Well, I wrote an article "I am this year" Yesterday, indicating that it is a bit of time recently. I can write some blog posts, and my friends are very enthusiastic. I will ask a question in my reply immediately, one of the articles caught my attention. I discussed the application proportions and depth of C and C ++ in my book 0bug-C/C ++ commercial engineering.

It should be said that I have been positioning myself as a technician. I am also interested in some discussions on technology. So I will temporarily put down some questions from other friends who are preparing to reply to me, answer this question first.

I have no intention of initiating a language competition. In my mind, there are no good or bad languages. The best way to use them is to disagree with this idea, so you don't have to look down. Thank you!

The original article is as follows:

Hello, instructor Xiao!
I am a graduate student majoring in computer science and have been paying close attention to your blog. What you wrote has helped me a lot and broadened my horizons. I have bought your book "0 bug C/C ++ commercial engineering path". I have read about 2/3 of the books. I think the content in the book has benefited me a lot, in addition to increasing experience, I have learned a lot of practical technologies that I did not know before. Thank you very much! Hope that such a good book will be available in the future!
After learning, Mr. Xiao is an expert in the industry. I am just a rare bird, but I am not quite consistent with some of the ideas in Mr. Xiao's book. Mr. Xiao has a profound knowledge of C language, but he does not have a deep understanding of C ++, or he does not have a deep understanding of object-oriented programming at least before writing this book ). Mr. Xiao encouraged us not to use polymorphism, inheritance, and other advanced object-oriented features, but to regard C ++ as a C language with more encapsulated features. The development method is still purely process-oriented, at least this is what I saw in my book. I think Mr. Xiao did not read any books about design patterns at that time, C ++ is always used as a C language with more objects. The basic library described in 0 bug C/C ++ commercial engineering, because it is only a data structure or library of basic functions, therefore, there is not much dependency on object-oriented advanced features. However, when developing something or software architecture on the application layer, the advanced features of object-oriented can effectively reduce system coupling and enhance system maintainability.
However, I still think that "0 bug C/C ++ commercial engineering path" is a rare good book. I personally just don't quite agree with the point of view on the use of C ++, this is my opinion. Thank you again, Mr. Xiao, for reading similar books!

My reply:

Hello, this friend. Thank you for your attention to my book. I can make some explanations and discussions on your questions.

Well, I agree with you about the proportion of C and C ++ in depth. In fact, I do not know much about C ++. You cannot understand the advanced object-oriented features such as polymorphism and inheritance. The design mode is not easy to understand. Oh, are you a little disappointed?

This is the case. I am a commercial programmer. I entered the game company in 1995 and officially became a professional programmer. Well, how can I say that pressure has been with me for so many years, the main cause is survival pressure.

All my friends know that I used to learn about architecture, and my computer software major was a half-way trip. I liked it, so I gave up my former state-owned construction engineer, I went to a company in Chengdu to work and write programs.

In this case, I start from a lower position than others and want to survive in this industry. What should I do?

First, I need to learn to acquire enough professional skills to meet my work needs. Otherwise, I will be fired. On the other hand, I cannot systematically study like a student in a university. Why? I have to write a program to make money for my boss so that I can get my salary for dinner.

Therefore, I think that many professional programmers in the society have similar learning models.Used for learning". That is to say, if you use any piece of knowledge, you need to make up for it. It's a kbook. You need to do more experiments and learn more details so that you can apply them to your work immediately.

Tell a joke. In the past, I had to make up for every job I found ~ For two months, why? Because of a job opportunity, I only have to deal with him. I cannot do anything about him. If I don't know what he needs, I will make up for it, in the future work, we will also learn while doing.

The benefits and disadvantages of doing so are obvious:

The downside is that I have not gone through systematic theoretical training. I don't know much about many things that have been determined theoretically. I have to experiment on my own to gain a deep understanding of them. In fact, this has taken a lot of detours and made useless efforts. In addition, I use words and terms in my work, which are different from those of many students, and it is not easy for everyone to communicate.

But the advantage is that we have no rules in our minds. We say yes in one language or technology. I may not say yes. I like to test it by myself to see if it can help me effectively in my work, if not, forget it. In addition, because I did not listen to many tests, but did the results of my own tests, many things were very aggressive and very practical, and very helpful for solving problems in practical work.

Therefore, in my opinion, it is really difficult to say that this problem is the best. We can become talented people from both class backgrounds and practical backgrounds, and we can't even get together. Do you mean no?

However, I think one of the most important things is that I have developed a habit of"Practice is the only criterion for testing truth", With special emphasis on experiment methods and methodologies, few people go to the cloud. Combined with our software major, I also summed up a sentence, you can understand:"Computers are the only criterion for testing programs".

A program, a language, and a technology. You say it is not good, it is useless, I say it is not good, it is useless, the computer has the say. I have a user requirement today. It satisfies the needs and is easy to develop. It is just a good stuff that cannot meet the requirements. It is false to say anything. This is my opinion on technology. What do you think?

Well, in C and C ++, I think so. Both are languages, they are similar to other Basic languages, assembly languages, C #, PHP, and Java... And so on, these languages do not have any elegance. Any language can solve the problem as a good language. What do you think?

What about me? In the early stage, if I had a process-oriented plot, I agreed. I learned a little about object-oriented, I can understand it, and I can use it, I think that's fine. After all, I am not a language expert and do not need to know a language as much as 100 points. As long as it can meet the needs of my program development, there is not much learning cost in the middle, because I cannot study for a few months without waiting for me to learn well, I lost my job and starved to death. Haha.

However, even if my salary increases slowly and I have already studied the C ++ language in depth, I am not interested in it.

I want to focus on it: Why am I not interested in studying it?

I must say that it is a development requirement.

For a long term program career, I think many professional programmers will be aware of a problem: the language is not important, the platform is not important, the technology is not important, the algorithm is not important, and the data structure is not important, in fact, it is not important.

What is important is how to meet user needs.

In development, user requirements are constantly changing. If programmers cannot abstract the commonalities of requirements, but are desperate to develop projects, they will discuss things on their own. Their own experience and technologies will not have an efficient accumulation, will be exhausted.

When we were young, we could work overtime, but what if we were old? Working overtime like a young man? I am almost 40 years old this year. I have worked overtime for the past six months. To tell the truth, I feel that I cannot afford it. Now it's okay. In year 35, I still can't help it. What should I do at that time?

At this time, I thought of the library, that is, whether I can summarize and summarize my previous work to summarize a set of efficient and basic development libraries that can be used for my own purposes without many bugs, by constantly adding, optimizing, and maintaining your own database, you can continuously support your future work and make your future work easier, instead of starting from scratch, finally, I am exhausted.

My later interests are mainly on this. Therefore, you can see the Engineering Library in 0bug-C/C ++ commercial engineering.

I think the maintenance and refinement of this database can help me to make money, rather than familiarizing myself with the C ++ language.

Here I also advise students majoring in computer software or friends who are engaged in the programmer profession. If you want to go a long way in this industry and become an expert programmer, it is best to prepare your own project library from now on. Only with this accumulation and accumulation can you pass the programmer's 35-year-old phenomenon safely and write the program to 60-year-old. Well, this is actually my personal dream. There are not many 60-year-olds in China. I want to be such a programmer.

The summary library is not difficult. A single person will go through different industries, but the software major remains the same. I will summarize these ideas and make continuous adjustments based on new requirements. Every adjustment strives for no bugs. In the end, there will be a set of libraries that actually belong to you.

Well, someone said at this time, "don't repeat the wheel !", The implication is that as long as there is a ready-made database in this world, you do not have to do your own useless work.

I don't know what you think. I found that the students in the school say the most, and I always think that it is more or less self-explanatory, it seems a bit boring.

The reason is very simple. In the future, everyone will go to work, and the machines, platforms, and demands will be constantly changing. In the process of writing each database, developers will predict the future needs based on their imagination, there is always something unsatisfied. If a person only relies on a ready-made library to write programs, well, what if one day no database is used for you?

I do not dare to think about it. At least, I do not dare to be such a programmer.

In fact, there are not many programmers who take up their jobs ~ In 2 years, I think it will happen that no ready-made database can be found for use.

My feelings,Most libraries are useless in most cases..

What should I do? Come on your own.

For example, let's talk about my recent real-time database problems.

You know about the binary method. I think this algorithm is the most favorite and library in colleges and universities.

We are faced with special situations. The bipartite method may be used to search for time points, match time periods, or fuzzy search for an offset location in a certain number order, then decide whether to further refine the search .... There are many special application requirements.

The most abnormal thing is that we need to give the inverse three to me by the bipartite method, that is, we can fuzzy find the three elements closest to each other, and discuss the relative relationship between the three elements in our calibrated query conditions.

There is also a large struct that we want to send in, which may be a floating point or a large struct containing a timestamp.

There are also returned values. We may need a precise index, an anti-trigger report, or a two-fold report comparing a time period and a time period.

These are all application requirements.

What should I do? Write it yourself.

Finally, we developed several modules in the light of the binary method. Well, they are basically pure C, and C ++ is useless. Why? This pure method has no physical data, I really don't think of the need for encapsulation, object-oriented. If I remember correctly the definition of this object, it would be a collection of data and its methods, and there would be no data. How to encapsulate it?

Encapsulate a class, which is all static functions? Then I would be better off using pure C.

There is also a tree. Let's play it. At last we made a very strange structure. Even we didn't know it was not a tree, a two-way linked list, and another two-way linked list on the upper layer, each element of the two is also coupled with each other to obtain the greatest convenience of searching for the road. Imagine that the railway bridge of the train has the reinforced steel frame, and we are the structure.

This is also a set of core data organization architectures defined after I have worked hard for a long time and learned a lot of advanced foreign experience. Finally, it proves that our architecture is relatively scientific, I wrote a set of search algorithms to automatically select routes, which is about 300 lines of code. A maximum of 40 pieces can be traversed to precisely locate a piece of data.

What does this mean? On the server, my cache can handle about 1.25 million pieces of throughput per second. Apart from the 0.2 million pieces of data written, I still have 1 million pieces of swap capability divided by 40, I can handle 2500 concurrent query requests per second. Currently, the highest number in China and abroad is only 500. Do you think I can make money by writing programs like this?

Speaking of cache, well, we may have learned a lot about the LRU algorithm. I think there are a lot of libraries in this field. But we didn't plan to use the library from the very beginning. Why? Efficiency.

All LRU algorithms are basically two-way linked lists. OK. Do you want to lock them in a multi-task environment? If it is not added, it will collapse.

If someone else's library is used, I can only add a large lock outside, that is, each block is exclusive when accessed, and the cache can only support access to one block at the same time, of course it's okay to do this. It's just that you don't have to make any money. Program efficiency is too bad.

What should we do? I figured out a solution myself, made some assertions and inferences, and finally turned the cache into a single-Write multi-read lock, locking each block separately, realizing this requirement, however, the database cannot be found. This is because of my design. What do you think is the exchange capability of the first 1.25 million blocks per second? Haha.

Well, for a few examples, do you think the problem can be explained?

Okay. Finally, let's go back to the discussion in C and C ++. Let's summarize it.

In my opinion, the requirements for language, school learning, and actual application are not exactly the same.

The school is "applied for knowledge", and the teacher cannot predict the industries and jobs that everyone will be engaged in the future. Therefore, all the features of a language must be handed over to everyone and the examination is required, therefore, it is good for the breadth and depth of a language learning. However, we will not talk about how to use a certain feature of the language to solve practical problems in future applications. Even many teachers do not know it.

In reality, it is "used to learn". It may not be accurate to a language or technology, but it emphasizes practicality. This can effectively solve the problem, but due to lack of theoretical support, easy to detour. Wasting a lot of useless work and unnecessary overtime work.

The best practice is to combine the two, that is, to study hard in school, to grasp the theory as well as to be as solid as possible. In the future, we should not carry too many prejudices or prejudices, learn many other people's tips, experiences, and practical technologies modestly. At the same time, be good at summing up and summarizing, and constantly form some of your own development ideology to become talented.

As for the C language that treats C ++ as an object with more objects, it does not use its high-end features. I think since it has been playing this role for so many years, it is quite good. In my library and work, it's also appropriate. Let's continue. Well, otherwise, my book is not the path to C/C ++ commercial engineering, but the path to 0bug-C language commercial engineering.

Haha.

Well, are you satisfied with the reply?

Xiao

This article from the "Xiao blog" blog, please be sure to keep this source http://tonyxiaohome.blog.51cto.com/925273/573178

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.