Today in the forum to see a post:
" Yes, I came from the C language from the beginning, if there is an electronic basis, I would like to engage in hardware development, now engage in C #, a bit like" copycat ", basically do not know why, or write C + + when the heart is the most static, in fact, I now use" class ", is to put some functions similar functions together into a class, and then use, not as good as the C function directly, a start to write the program when the reception is a process-oriented thinking, object-oriented details of the implementation of the process is also
Now that the project is almost done, c,mfc,c# are in use, in fact, the heart is really very contradictory, just want to learn a language, from the depths of the soul, I want to write C + +, every time in the late night to write C # write to the head, will hiss exhausted shouting "I want to write C + +", that feeling, Like Mitsui Life to Anxi coach crying said "I want to play basketball" a look, but every time in the project encountered C + + solve the problem, I will "make a cheap" Miss C #, contradictions, people is the production of contradictions = = "I am the product of c++&c#"
Having read the above discussion, I think the fundamental problem is not the language. Moreover, all problems are rarely attributable to the limitations of language characteristics.
This reminds me of a concept that has been highlighted in the Book of Code Encyclopedia: Programming in a language, rather than programming it in one language.
The difference is that in a language programming, thinking is limited by the language characteristics, the depth of a language to programming, in the first place is our thoughts, we must first determine our thoughts, and then to use the language characteristics to achieve it. Do not confine our thoughts to the characteristics of language.
Whether it's c,c++,c#, we can write good code, which, the most important factor, is your thoughts, your ideas, not the language you use.
Example One:
Assertions are code that is used during development to allow a program to self-test at run time. Assertions are a powerful tool for a good programmer, but some languages do not provide an assertion mechanism. Then we don't have to assert it. Not too. We can simply implement an assertion, for example, in C:
#define ASSERT (flag)/
{/
if (!) ( Flag))/
printf ("ASSERT failed! file=%s, line=%d./n ", __file__, __line__);
}
Example Two:
A very important concept of object-oriented is encapsulation. When dealing with global data, it is generally not directly to the client to access the data itself, but to use accessor functions. For example, there is a static variable in a class that typically comes with two functions: 1 set*** (),//Set function, 2 get*** ()//Access function. The benefits of this are: 1 details of the implementation of the external hide. 2 Easy to expand, if one day the variable to become a structure, the client part can be basically fixed, but only the accessor function can be modified. 3 There is a central control point, easy to locate the problem.
However, if you use the C language, the process-oriented, can also use this method to achieve the benefits of encapsulation. The answer is yes. For example, if you have a global variable with two files that you want to access, you can define the file as static and only allow it to be used within the file that it defines. Then, define two non static accessor functions for the client to access this global variable. This way, you can also use the benefits of encapsulation in C.