How should you learn C ++

Source: Internet
Author: User

How should you learn C ++ (and programming) (Rev #1)

 

By Liu weipeng (pongba)

C ++'s loose (http://blog.csdn.net/pongba
)

 

Javascript is the most misunderstood language in the world. In fact, C ++ is not. C ++ learning methods that are widely used in the industry are the best practices. I also took many detours while learning C ++, wasting a lot of time.

 

Why are there so many mistakes? There are three main reasons: first, there are too many details about the C ++ language. Second, some famous C ++ books always imply the importance and fun of language details (whether intentionally or unintentionally. Third, the development philosophy of modern c ++ libraries must use some technical details (but note that it is library design rather than routine programming ). These jointly shape the overall mentality and philosophy of the C ++ community.

 

The first article alone may not be able to generate a climate, and there are also a lot of details in other languages (although it is a little cool than C ++). For JavaScript, scope rules, name searches, closure, for/in, these are all details, and they also violate intuition. But the concept of programmers in many dynamic languages I guess is about where to use it. But C ++ is different. People who learn C ++ have a potential mentality similar to being hinted, that is, you must thoroughly understand the language core before you can write beautiful programs. This is the first error. The second reason for this consciousness is C ++ books. There are countless C ++ books on the market, but one common drawback is that there are too many books about language details-C ++ gotchas, Objective C ++, more effective C ++, but it is understandable that C ++ is such a language: to satisfy the needs of modern programming concepts, especially for C ++ library development, you must pay attention to the language details, and even use the language details in C ++ has become a learning topic. For example, the C ++ Template did not think of the template meta-programming at the beginning of the design, but did not expect the C ++ template system to be completely Turing, this has led to the shock of modern c ++ design and C ++ template metaprogramming. Why are these technologies so shocking? For example, It's like a piece of land where everyone thinks they are already very familiar and have no secrets at all, one day someone dug the ground and found the most abundant oil. Although C ++ has some details before, it is still easy to grasp, but it is a happy old times for C ++ programmers, because everything in C ++ is at a glance, everything is figured out. However, the birth of modern c ++ design tells people that "You have not mastered the details ." As a result, C ++ programmers were once again excited by their long-lost passion and stepped into the details swamp. In particular, template programming further explores the details of C ++ to the extreme-why do we care about the priority of implicit conversions involving class objects? Look at Boost: is_base_of to see how strange it is. But the biggest problem is that there is a reason to pay attention to these details: to develop a modern Template Library and to develop an active library, we must use the template programming technology, to use the template programming technology, you must use the language's leading role character, enable_if, type_traits, and even c macro, which has never been a wave before, to see boost :: the Preprocessor knows how strange it is, and even the Turing completeness of the C macro (during the pre-compilation period) is mined. Why? Fun? Advertised? None. the actual requirements of the Development Library. But this is also the biggest sorrow. In boost, the best teaching material that uses the language details for magical task completion is boost: foreach. This small facility's exploration of the language details has reached the level of astonishing, if you don't believe it, try to check its source code first, and then read the article about it by the author. And boost: typeof is also unwilling to follow-there are too many technologies in the C ++ language that are "discovered" rather than "invented. Didn't everyone who had no intention of setting these language rules begin with Les?

 

Because there is no variadic templates, we use macro to add the default template parameters to achieve similar results. Because there is no concepts, people use templates to add the details of destructor to accomplish similar work. Because there is no typeof, people use template metaprogramming and macros to add endless details to achieve the goal... The DIY spirit of C ++ developers is not weak.

 

However, if you only need to develop excellent libraries, these details are still excited. At least until C ++ 09 appears and the compiler vendors keep up with it, it is a last resort. But what about our vast number of C ++ programmers? The masses are easily misled, and I used to be. I thought it would be better to grasp more language details, but actually those language details are usually not used for programming. Although many details in C ++ are useful in the hands of library designers, ordinary programmers do not need to pay too much attention at all, especially with no actual motivation. General coding practices, basic programming capabilities and basic skills, and even basic programming theories and algorithm design. It is something that really requires time to master.

 

Learning best coding practices is more important than learning C ++. Reading good code is also more effective than writing junk code in poor coding methods. Direct, Clear, clear, and kiss visualization is more important than coding tricks...

 

Avoid asking any language details unless necessary. This must be a problem encountered in actual programming, so that even if you need to ask details, it is also the most time-consuming, lazy principle. A programmer who has mastered the basic programming concepts and has strong learning ability can compile a qualified program even when programming in a strange language, even if the Bible of the language is pulled from the index.. Ten years of learning programming doesn't mean that every language requires ten years, so you can learn a few languages in your life. If you want to learn in alphabetical order, you don't want to learn Ruby in your life; ten years of learning programming doesn't mean that you can start programming by thoroughly understanding the language features. In practice, improving programming is the most important thing.

 

It is a psychological question as to why the philosophical details of the NLP language can become a wild fire in the community. Imagine that when people discuss issues on the Forum, a person with a very detailed grasp of the language will certainly be able to get more admiration. However, most of the problems on the Forum are minor issues, therefore, the true ability to solve practical problems cannot be revealed. That is to say, knowledge-based people can gain more admiration, and the latter will become the power and the weight of imitation. However, true programming skills are irrelevant to the details of the language. The use of a language can help you express your intention in the best way, however, being proficient in a language does not mean you should remember all its sides and corners. Understanding some common sense and having the basic intuition of programming, checking books when encountering some details and errors is the most time-saving method.

 

The C ++ book, Bjarne's Bible "the C ++ Programming Language" is built on the roof. Large-scale C ++ programming is quite pragmatic. Accelerated C ++ is the best entry. C ++ templates is for reference only. "C ++ template metaprogramming" is a game that can be played by people with excessive energy. Common programmers do not touch it. ISO. iec c ++ standard 14882 is not used for reading. Bjarne is recently engaged in C ++ education. new books are definitely expected.

 

P.s. There are many wonderful articles on G9's blog about how to learn programming: here, here, here... In fact, I suggest you roll over the blog of the G9 boss.

 

Another p.s. Ticket? I just gave a book like "C ++ beginners must read. There are countless books in C ++, and many well-known books are also numerous. However, some books may easily give beginners the illusion that "learning C ++ should be like this ". For example, a friend mentioned "High Quality C/C ++ programming". This book is valuable, but not suitable for beginners. It is easy for beginners to read such a book. In fact, the correct attitude is that details are necessary. But the details are secondary. In fact, I think I should first learn how to express ideas with pseudo code. I don't see the code in "Introduction to algorithm? Code in taocp? Oh, by the way, they are self-built languages, but the purpose of this language is to prevent the programmers from forgetting to write the program to complete the function at the beginning, I think that writing a program is a battle against language details. Bjarne said that the correctness of the program is the most important. The boost encoding standard also lists the correctness before the performance.

 

In addition, once a correct idea of learning programming is established, what books are actually useful (as long as they are not too spam. All of them are used as reference books. It's basically the right thing to do when you use them from directories or indexes.

 

In addition, p.s. myan and G9 both gave a lot of wonderful insights. I have to add another p.s. I will not extract the details. If you read this article, please read their comments. Do not forget to repost their comments to the reporters :-)

 

Many of my friends asked me the same question. Do you want to learn C ++. In fact, this question is meaningless. The "learning C ++" and "not learning C ++" are meaningless. Why? This problem is superficial and even impetuous. What is important is not the language you master, but the ability you master. In the words of myan boss, "what is important is the training process, not the result. What you need is your thick leg, instead of the bag of salt on your body. ". In addition, the significance of learning C ++ is actually really an intoxicating wine. A system-level language like C/C ++ must involve some underlying knowledge in the learning process, knowledge such as memory management, compilation and Connection System, assembly language, hardware architecture, and so on (note that this does not include too many languages ). These are the so-called internal strengths (in fact, the most important internal strength is the self-learning ability honed by long-term learning ). Joel's abstract law of vulnerability mentioned in Joel on software is very beautiful.

 

Therefore, the answer is that it is not the language you have mastered that makes you a master. Mastering C ++ may not make you a master, if you are not proficient in C ++, you may not be able to become a low-handed person. I don't think everyone will doubt that if G9's boss wants to copy C ++ into a project, it will be more beautiful than most people who think they are proficient in C ++. So the key is not the surface of the language, but the underlying contradictions. Of course, that's not to say that we should never learn any language. According to the logic of Cao, "the language of the world is only imperative and declarative ". C ++ is the most complex one in the former and supports the most extensive programming paradigm. In the words of a teacher at the mathematics department admission conference, "you have learned all mathematics. What else can't you learn ?". Learning Language is a way. If you use it to hone yourself, you can. If you use it as the key to learn the underlying knowledge of the system, you can. If you use it to learn how to write excellent code, how to organize large programs, and how to perform abstract design, you can. I don't think it's okay if you drop the book bag and chew on the details (unless you have to use the details, like the coder of the boost library ).

 

Then, let's borrow the words from the silver bullet and our profession OF g9's boss:

 

What is the relationship between silver bullet and our career development? Simple: we have to use time to learn and solve essential difficulties. New technologies bring convenience to experts. Cainiao don't need to be saved by new technologies. Following the previous metaphor, first-class photographers will not lose their rice bowl because of camera upgrades. Instead, they may use advanced technologies to make great achievements. Because of the difficult nature of photography, it is still the artistic feeling of photographers. Popular technologies are equal to cameras. Keep chasing new people, learning this framework, that software, is like studying the specifications of different cameras all day long. The ins and outs of popular technologies are like photography technologies. Why is this framework released? What other frameworks does it solve? Where does it apply? Where is it not applicable? What new design does it use? Which old designs have it improved? Why is forever. When chatting with friends, I mentioned that Steve McConnell's professional software development cited a survey, saying that the half-life of software development technology is 20 years. That is to say, half of our current knowledge is outdated in 20 years. Not bad. My friend joked: "We should say that half of the IT industry's technology is outdated 20 years later. The outdated technology we have learned far exceeds this proportion. It may take five years for someone to stop ". Although pessimistic, we can see the importance of choosing the learning content. Learning essential skills (technologies are outdated sooner or later, but often used to grow new) has another advantage, that is, you don't have to look at your beloved technology when it is challenged. C/C ++ is outdated, as long as there are other system programming languages. If Java is used up, it will fall. I may not be able to use. net? What's Ruby like. If you are not comfortable with it, switch to another dynamic language. What if J2EE is deprecated? Maybe we can't do the distribution system anymore? More examples are provided here.

 

In a word, only one person is a real silver bullet. The goal of career development is to turn yourself into a silver bullet. At that time, you are no longer a human, but a human bullet.

 

Finally, let's end with some of my views on how to learn C ++ (and programming) extracted from many interviews in Bjarne, I just translated some of the most important paragraphs. Of course, others are also important. These paragraphs are extracted from all the interviews in Bjarne, therefore, it is strongly recommended that you view all of them ):

 

I suspect that people think too little about what they want to build, too little about what wocould make it correct, and too much about "efficiency" and following fashions of programming style. the key questions are always: "What do I want to do? "And" How do I know that I have done if? ". Strategies for testing enters into my concerns from well before I write the Firat line of code, and that despite my view that you have to write code very early-rather than wait until a design is complete.

Translation: I feel that people are paying too much attention to the so-called "efficiency" and the trend following the programming style, but seriously ignore the issues that should not be ignored, for example, "what kind of system I want to build" and "how to make it right ". The most critical question is always: "What do I want to do ?" And "How can I know if my system has been completed ?" Let me take it for example. I will consider the test scheme before writing the first line of code, and this is still on the premise that I should code before the design is complete.

 

Obviusly, C ++ is very complex. obviusly, people get lost. however, most peple get lost when they get diverted into becoming language lawyers rather than getting lost when they have a clear idea of what they want to express and simply look at C ++ language features to see how to express it. once you know Data absreaction, class hierarchies (Object-Oriented Programming), and parameterization with types (generic programming) in a fairly general way, the C ++ language features fall in place.

It is true that C ++ is very complicated. It is true that people are lost. However, the problem is that most people do not get lost because they first have a clear understanding of what they want to express, but find the appropriate language features in the C ++ language. On the contrary, most people are lost in the details of the jungle on their way to being a language lawyer. The fact is that C ++'s numerous language features are clear simply by having a fairly general understanding of data abstraction, class architecture (OOP), and parametric type (GP.

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.