The C ++ compilation language can cause the program to jump out of the loop body and switch statement and continue to execute the next logical statement. It is not suitable to end this loop elsewhere, and then judge whether to execute the next loop. Therefore, the code generated by the c ++ compiler must be more efficient than the compiled code of vb.
The difference between a good program and a great program is whether it has good support for error handling. In fact, if you handle errors first in implementation, rather than at the end, the entire program development and testing process will be more perfect. However, error handling can only be consistent with the content supported by the language.
Vbscript supports basic error handling functions. By default, errors in vbscript cannot be captured. When an error is suspected, call the on error resume next function and check the error object. The error handling in C ++ is better, because "Exception Handling" exists. The following sections in this chapter will be detailed.
Minimum dependency
As mentioned above, C ++ compilation language, that is, C ++ code has been converted to machine code before execution. As long as this code does not depend on external dynamic link library (dll ), C ++ can be moved to other machines and microprocessors running the same operating system without the need to install additional programs, while java runtime libraries must be installed before moving java programs.
Use existing code
Since c and C ++ have been around for many years, and there are a lot of available code, your server components can use the existing c/C ++ code or library. For example, the Statistical Library and the c interface to the old system.
Maximizing com features
Com is very similar to C ++. In fact, don box (the authority of com) writes in the first chapter of his book "essential com": "com is a better C ++ ". He explained how the com specification was produced from the C ++ language rule. By understanding C ++, you will have a deeper understanding of com. Some languages cannot use all com features, but almost all com features can be used in C ++.
Knowing when to use C ++ to compile a language is also important. Imagine those who have maintained code for a long time. If some C ++ programmers do not support C ++, developers have to turn their eyes to other languages that they are familiar.
When changing the C ++ component, you must re-compile the component code to see the results of these changes, which takes a long time for development. C ++ cannot use Notepad as asp page code, change a line of code, and load the code again to get the result. Therefore, if some work needs to change frequently (such as prototype), do not use C ++.
In C ++, more protection is not provided for some fatal errors. It is easy to write a code that causes component crashes. This is the price paid to provide fast code. C ++ does not stop to check whether the code runs according to the design. Whether the program does not crash depends on the developer's skills. If you spend less time or just learned C ++ in this aspect, it is best not to use C ++.
C ++ can be used only when you are aware of all the mistakes that are easy to make in C ++ and spend a lot of time before detecting components. If you want to quickly and easily create a component, the execution speed of this component is not considered. use vb! The best way to learn new things is to use existing skills. For asp developers, they have learned many skills required by C ++, especially the jscript syntax and the Object-Oriented Programming Concepts of activex or com.
1. jscript
Most asp developers use jscript to use dhtml in the browser. The syntax of jscript is very similar to that of c. Therefore, if you know jscript, you can understand the basic c syntax. Of course, it is only a subset of the C ++ syntax. C ++ has many additional syntaxes to support object-oriented programming. This is what we will do next.
2. Object-Oriented Programming
If you have used classes in vb, you should be familiar with any com Object and document Object Model (dom, because we already have the concept of Object-Oriented Programming (oop. As mentioned earlier, the difference between c and C ++ is that C ++ supports C ++-oriented compiling languages.