Learning C ++ is equivalent to mastering all languages.

Source: Internet
Author: User

"Mastering all languages" may be a little exaggerated. I don't think too much about "mastering all the popular programming languages on the market.

How to define "learn C ++? I think I have read some typical C ++ books and articles written by foreign masters. If I have two or three years of programming experience, the most important thing is that I am willing to study and think more, c ++ should be learned. Of course, it is far from proficient.

It is defined as "Learning" because such programmers can do some difficult projects on their own, probably more competent than many programmers who claim to be "proficient in XX language.

If you are proficient in a language that is actually familiar with a library, I have nothing to say. I think learning a language is learning programming skills or ideas, not a library. If we have different definitions of "learning language", there is no common discussion basis.

The programming languages and libraries used by the projects I am currently participating in are brand new to me, problems encountered at work are sometimes very difficult (for example, encapsulating the mpich library into an interface that can be called by Python ). However, because I still remember some basic design skills of C ++ (of course, I am familiar with C ++ development tools), it is easy to solve these so-called problems.

One problem I encountered at work was that a program written by an Architect (developed using the Python language) always crashed when I exited. This problem took two or three weeks and was not solved yet. After I took over the problem, it took me half an hour to ** completely ** solve it, and it didn't hurt much brain cells, because the steps to solve the problem were completely mechanical to me.

First, I pulled the program to the Linux platform for debugging. When the program crashes, core dump is generated. Then I loaded the core file with GDB to determine the function call stack during the crash. The result shows that a crash occurred when calling the MPI: Finalize () function. This function can be considered as a function that releases a certain resource of the mpich library.

Without further debugging, I can guess the cause of the problem. Python, just like most popular languages, claims that its resource management is automated. The problem is that the resource here only refers to memory. However, many people do not care about resource management during Python development. Even if they are willing to manage resources, they use the most tedious technology to manage them. It must have been a problem with resource management.

Well, the problem I encountered is not that simple, because the program itself is distributed (multiple processes run on multiple machines), multi-thread, A single function also involves a lot of messy error handling processes (this error process is also disgusting to my C/C ++ programmer ), therefore, it is still difficult to locate bugs completely through the debugger (the python debugger is not that convenient ).

In addition, I am not interested in reading code written in distributed, multi-threaded python.

I simply applied the technology of resource retrieval, I .e. initialization, in C ++, to write a new resource management class and put the code for resource retrieval in the class constructor, place the resource release code in the destructor. Then, replace the original code (automatically replace it with the text replacement tool.

Class Definition:

Class mpismartmanagement:
Def _ init _ (Self ):
If MPI:
If not MPI. initialized ():
MPI. INIT (SYS. argv)

Def _ del _ (Self ):
If MPI:
MPI. Finalize ()

Call:

SP = mpismartmanagement ()

Sorry, I didn't explain some complicated debugging skills about how to debug distributed multi-threaded programs.

I have an example of these complicated debugging skills. It's like a flood of water, so a place is in a mess, but many heroes are generated in the flood fighting and rescue process, in the process of rebuilding homes, GDP is pulled up (up) Again, so bad things become good.

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.