How to learn C, C + + language

Source: Internet
Author: User

How to learn C language well

Someone asked the following questions on the Cool Shell message board

Keep_walker :
I read this article tonight.
Http://programmers.stackexchange.com/questions/62502/small-c-projects

I also met the same problem as the foreigner who asked. Can you give a suggestion to a programmer who has trouble like this? Thank you!

I believe that this may be a lot of friends of the problem, I have such a feeling before, programming to a certain time, the ability to find the bottleneck, neither deep nor solid, dabbler. For example: You use Java and. NET for a long time, these languages with virtual machines are convenient for development convenience, but may not be very good for programmers for two reasons:

    1. The virtual machine masks the system calls of the operating system, as well as many underlying mechanisms.
    2. A large number of well-packaged libraries also block many implementation details.

After some time, you will find that you know it, do not know why. I used to write a "Java NIO Library selector mechanism analysis (up, down, continued)" in the csdn, I said in that article (ironically) Java programmers do not understand the underlying implementation, so it is difficult to learn more solid technology. At this point, some programmers will not naturally want to learn the underlying technology, it is natural that C language has been raised.

Here are some of my suggestions for this friend:

    • encourage and cheer for you . I encourage you to want to learn C language ideas and spirit, many people think C language studious, in fact, not yet. (You can take a look at the "C-language puzzle") Now the society is more concerned about the fashionable technology, but ignored this popular 40+ years of C language. If a technology can be popular for more than 40 of years, this is the technology you need to focus on and learn about, not just the technology that comes out (over-hyped technology, the history of Windows programming). This is the spirit of steadfast.
    • don't look for excuses . It's not easy to go down this road, don't make excuses for yourself. The last thing I like to hear is a " busy, no time " excuse. I used to do projects in the bank, as early as 9 o'clock to 10 o'clock in the evening, Monday to Saturday, I can smoke 1 hours a day to read books and research, a year down can also be intensive reading 5, 6 books. I am now working on the project and the recruitment task is very tense, just born child only own and wife two people, but also need to prepare lectures, but I still can find time to read articles to write articles to maintain cool shell. So, I can tell you, " time is like a cleavage, as long as you are willing to squeeze, there will be."
    • learn C language and system programming . I think there are four ways to learn programming well: languages, algorithms and data structures, system calls and designs .
      • language . I can tell you that there are two major themes in C. You are good at learning, one is memory management, one is a pointer! The severity errors of more than 90% of the world's C/s + + are all related to these two. Don't look at rectification's book, it's a bad book. Recommend this book to you "C programming language (2nd edition • New version)"
      • algorithms and data Structures . I think that the implementation of the C language algorithm and data structure is the most cool thing. Recommend you read this book-algorithm: C language Implementation (part 1th to 4th) basic knowledge, data structure, sorting and search (original book 3rd edition), and the classic "Introduction to Algorithms"
      • system Programming . Two books recommended under Windows--"Windows Programming" and "Windows core Programming", Unix/linux recommended two books-"UNIX Advanced Environment Programming" and "UNIX Network programming Volume 1, Sockets" "UNIX Network Programming Volume 2, interprocess communication" In particular, "UNIX Network Programming" this book, follow, regardless of Windows or unix/linux, are the same.
      • system Design . On the design side, I fully recommend the "UNIX Programming Art", after reading, you will understand what is the real programming culture. Then, when you see certain words from Windows fans, you know what's called laugh.

If you can finish these books in 2-3 years, and all of them, then you will understand what is the feeling of the mountain small! It took me 5 and a half years to really read all these books. Finally, I wish you good luck! Efforts!

——-Update: 2011/03/29 20:00 ——-

I think this article mainly wants to tell you a few things:

    • Programming to a certain time, you need to understand the underlying system mechanism, otherwise, know it does not know why.
    • I do not deny the logic of non-C programmers, the real logic is-if you want to understand the underlying mechanism, please learn the C language and the operating system.
    • More than 40 years of unix/c have a profound impact. This includes affecting Windows. If you want to follow, be sure to understand UNIX. That's the real root of computer culture.
    • Don't think about the problem in a superficial way. For example, do not assume that a DBA will not take into account the database engine's memory page problems. Also do not assume that Web programmers do not need to understand the performance of servers and scripts in the background and TCP/IP issues.

Master often have a strong system of basic knowledge, the surface of things is always superficial.

How to learn the C + + language

Yesterday wrote a How to learn C language, someone replied to ask me how to learn C + +, so I put my personal learning experience here, I hope it is useful to everyone. First of all, because of how to learn the C language in the algorithm and system, so this is only about the C + + language.

    • C + + is the hardest language . The most difficult programming language in the world may be a non-C + + mo. You must not think that a few days can learn c++,c++ learning curve is quite bt, you can read this article. C + + is a very free language, free to a bit of BT and terror to the point. I even think C + + is not a mature programming language, because it's too easy to make mistakes. Therefore, you must be very cautious at the beginning, and the C + + as a difficult to train the beast to see .
    • ask "Why do you want to do this" question . Learn C + + must ask a few more "why is this", "with what to do" problem. For example: Many people know that C + + has copy constructors and initialization lists, but do you really know why you have copy constructors? Why do you want to have a list of initializations? Why should there be a template, why should have rtti, why not other? Is it just to make a language cool? Not at all, any of the feature in C + + has some real reasons, you have to understand why you should design C + + for such reasons, you can learn C + +. Take a look at the book "C + + evolution and Design".

    • read a book, a large number of C + + books . You can read in the following order (these books, I spent about 4-5 years, today I still review)
      • C + + Primer, this primer may make you eat very painful, all the characteristics of the language and why are in it, read well. Of course, the C + + 's father wrote "C + + programming language" is also good. It would be nice to read one of the two books (I see the former).
      • Understanding C + + syntax is just the first step of Long March, you need to look at "effective C + +" and "more effective C + +" These two books are not thick, but I have seen from 02 now, every time I read a new experience, these two books are too classic. If you are not familiar with C language, these two books would let you go back to the C language class.
      • Think in C + + is another classic extreme book, learn C + + must read, but the Chinese version of the translation is very bad, so read the English version of it. The
      • Meditation on C + + is also well worth reading, which teaches not programming, but the method of thinking, which is quite precious.
      • Exceptional C + + and more exceptional C + + give you a look at the solutions to various problems and some common classic mistakes.
      • Advanced C + + and modern C + + allow you to know the various magical uses of C + +.
      • generics programming and STL are the things that put C + + in practice to the extreme. Very powerful. stl--Template Libraries (containers, algorithms, and function objects) are not to be obeyed.
      • Exploring the C + + object model in depth gives you an idea of what C + + is like under the compiler, so you know that C + + performance is not bad. This is too critical for a C + + programmer. I have written before the "C + + virtual function table parsing" and "C + + Object memory Layout" belongs to this category.
    • In contrast to the Java language . I personally think that Java has made a lot of adjustments, specifications and limitations to the immature language of C + +. So, in contrast to Java and C + +, think about why some things can be done in C + +, but not in Java. For example: Java exceptions are required to catch, otherwise it will be compiled do not pass. Why doesn't Java provide operator overloading? Why does Java introduce interfaces to do multiple inheritance? Why doesn't Java have a stream of I/O characters like C + +? Why does Java not support pointers? Why Java can be garbage collected? Wait a minute. Java embodies a lot of object-oriented design, learning Java can help you learn how to better use C + + to program .
    • Object-oriented design . While object-oriented may be a scam. But I think some of the practices in object-oriented design are very good, such as the single principle, the dependency inversion principle, and so on, are very classic. "Design mode" must be read, "Object-oriented analysis and design" can be read. but it is not possible to design patterns for the center of programming, but should be used in design mode to solve the lotus root .
    • Class Library Learning . See how MFC encapsulates the Windows API, see how Aces are object-oriented, see how boost plays object-oriented, and see how cppunit is designed. Of course, there are too many design patterns in Java's JDK to refer to.

I hope not to scare everyone, and welcome you to add.

————— Update 2011/03/30 19:20 ————

Update several ideas:

    • 1) I am not good at writing reviews, so the recommended books may make you feel a little bit, you can read the book reviews on the watercress or china-pub.
    • 2 C + + has a lot of kinky tricks, some very bt, including virtual function table, perhaps some people feel a little boring, but I think it is very interesting, on the one hand can understand the implementation of a language details, on the other hand can broaden the thinking. I have benefited a lot from learning this knowledge.
    • 3) The above is my personal learning process, I think it is very effective for me, so is the experience.
    • 4) This kind of article on the internet has a lot of, I am not the first to write such an article, I do not write the best, I do not want to use a lengthy talk about what. Just want to give you a look at the general study. After all, C + + is profound, no article can say well. It's easier than that.

How to learn C, C + + language

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.