The difference between C and C ++
The design language has two completely different perspectives.
One is from a hardware point of view, and all languages are designed for easier handling of hardware. From this point of view, all high-level languages are nothing more than macros for machine instructions. Compilation is to facilitate the identification of machine instructions, and C and assembly is strictly corresponding, remove the compiler optimization possibilities, corresponding to some kind of hardware, read C code, you can make up for the brain assembly. Java, or python, will have to be turned into machine instructions.
For example, when writing the kernel, the use of compilation is very cumbersome things, this time using C can be greatly simplified. But at the same time the brain or to the use of memory, a variety of data structures in the memory of the location, size, status, the value of various registers and the state has a very clear understanding. So the use of C in this case is more to facilitate the control of hardware, in some cases but also directly write assembly, or through inline assembly to control the hardware. For example, after the bios self-test, will jump to which memory location? Where is the processor will be? What time is the processor in this mode? Can read the memory size is the number of bytes? Which register can control mode conversion? What if I want to do basic screen printing with bios function? When the system is initialized, is the directory of my double page table stored in that virtual address location? Where is the corresponding physical address location? If the hardware does not allow me to manipulate the physical memory directly, how can I allocate the physical page by manipulating the virtual address? These problems, and hardware are very strong association.
The other is from the perspective of solving the problem. How the problem can be broken down, how to improve the quality of the code. The main technique is the abstraction and combination of basic elements (according to scip). From this point of view, it is not important that the machine instruction is what the compiler will translate the code is also less important. The important thing is how to build a good program structure, in order to establish this structure, the programmer may use a variety of paradigm programming in different situations.
Such as the use of oc write iphone application, although oc on the c language is fully compatible with the language, but I do not care how the instructions are implemented, but concerned about how to break the problem, what use cases, how these cases Of the operation, such as database operations, network operations, these operations are still necessary to add a layer? How are these different levels of components connected together? What interface do I need to connect to them? Another example is a TableView Cell, whether there will be a lot of similar cell? Do I need to abstract these data structures? What should I do if these data structures are changed later? If the control flow needs to be reversed, this time I was using the delegate mode, the observer pattern? Or use block such a closure syntax? Which can make my program structure simpler, less code? Even in the optimization time, most of the time I just look at the function call time, memory occupied by the state, through this information to understand how I adjust the structure of the program. At this time I understand the memory and CPU is rough.
Of course, the two are actually two issues of a view. C language through the type of conversion, you can also achieve object-oriented, generic, after all, regardless of what paradigm, and finally to be translated as a machine instruction. If you are more peculiar, you can also use assembly to object, it is not impossible. On the other hand, it is possible to use C language or assembly to better control the hardware in python. The question is, in two completely different situations, do I have to deviate from my focus?
C ++ is a language that takes into account both perspectives, and C ++ hopes to control the hardware well and want to break down the problem. As for the final C + + in the end is good, I think this is a matter of opinion. In the actual work, if it is only used C + + work, of course, put all the features of C + + and familiar with the familiar library just fine.
For myself, I will learn a few more languages. When used, which is easy to use which; different framework which, on which to use. With the most concise way to solve the problem, is not the fun of programming it?
Thank you for your attention!