Development tools Visual C ++ vs. Delphi (2)

zhaozj2021-02-08  469

Application Frame: MFC? Is there a KFC popular? Application Frame, sometimes referred to as an object frame. The framework used by Visual C is MFC. The MFC is not only a class library that people usually understand. (Similarly, Delphi's VCL is not just a control library, although its name is "visual control library".) If you choose MFC, a program structure is selected, a programming style. The MFC appeared early in the era of Windows 3.x, and the Visual C of the time was 16 bits. After these years, the MFC is already very mature. However, because the prototypes have been earlier, the MFC has been behind the VCL behind the VCL. Although Microsoft's update to MFC did not stop, I also read "as long as Windows, MFC will not overtime", but like the OWL framework of Inprise (original borland), the fade out of MFC It is also a morning and evening. In fact, the MFC is the product of the same era of OWL. Owl is no longer there, how can MFC do not "live peace"? If the MFC youth is always stationed, Microsoft's developers will not "privately" to develop ATL-based WTL. Of course, the status of the WTL cannot be compared with the MFC, which is not a framework for Microsoft's official support, and the functionality of the package is quite limited. However, at least it is also lined out of the lack of MFC. I thought that the advancement of an application framework is its entrustment model, that is, the package mechanism of Windows messages. Don't say it to the Windows API package. Datong, there is no technical content. If you are happy, you can also write a class library to package it. But the package of Windows messaging mechanism is not so easy. The most natural package is a virtual member function. If you want to respond to a message, you will overreload the corresponding virtual function. But I am unexpected, MFC uses "ancient" macro definition method. The advantage of using macro definition methods is to save system overhead of virtual function VTABLE. (Due to a lot of WINDOWS, the overhead is not too small.) However, the shortcomings brought about the map is not intuitive. For MFC, it is "too intuitive". Its message mapping code is visible, but "persuaded to touch". Good ClassWizard in VC can automatically generate message map code, which is convenient to use. However, the mapping method of the MFC is too late compared to the VCL's entrustment model. Delphi's Object Pascal has introduced new features such as components, event processing, attributes because there is no "standard burden". Since Kung Fu is done in the compiler level, the source code generated is very simple. It seems that VC is "Let the Framework", and Delphi is "Let the Language Movement". I want to give an example of the package of the string operation to illustrate the advantages and disadvantages of the MFC and VCL. In the MFC, the CStringList class has functions such as joining, acquisition, deletion, but the TStringList class of the VCL except for the above functions, from the comma-separated string, stream input and output. But the same string replacement function, VCL StringReplace is 2 to 3 times slower than the MFC's cString :: Replace. In general, VCL packages are more high, more abstract than MFC, but inevitably brought about some partial execution efficiency slightly lower than MFC. This is like a low-level language (such as compilation), which is higher than the advanced language (such as BASIC), but the programming efficiency is low. Fish and bear's pauses are not good. Another advantage of the VCL ratio MFC is support for exception handling, and a large disadvantage is to support multi-threaded support. Most of the VCL is not for multi-threaded optimization. Although VCL provides a simplified multi-threaded operation, it is only simple to use worker threads. If the thread is going to deal with the interface, it will become troublesome, because in addition to the main thread of the application, any thread cannot access any visual VCL component.

You have to use the SYNCHRONIZE method to wait for the primary thread process and then access the VCL component in the main thread. And the MFC has no such limit. Stability and Perfection: VC is the old brother VC is more stable and perfect than Delphi. The development history of VC is longer than Delphi, and Microsoft's overall strength is strong than Inprise. The VC framework MFC has experienced so many years of development and improvement, and the function is very comprehensive, and it is very stable. BUG is very small. Among them, you may have more bugs. And there are third-party specialized tools to help you avoid these bugs. This is not easy to do this. Don't underestimate this, many professional programmers are to choose VC for this. Because although the VCL is higher than the abstraction of MFC, the encapsulation is high, but the improvement of development efficiency is limited to the master. And if you encounter a blame, debugging for a long time, I found that it is not your code wrong, but the BUG of VCL, what do you think? Although the possibility of encountering such problems is small, the impact on the image of VCL is not small. Delphi's IDE is too resource, the start speed is too slow, and some graphics driver conflicts, BUG in the VCL, the debugger is not strong enough, there is no protective measures for unstable third-party controls ... There are a lot of problems, Delphi is not as good as this. VC. I hope that Inprise can go to the next level. By the way, I saw some people in the Internet unstable, saying more than 20 illegal operations in a few minutes. Delphi is not as stable as Visual C , but it is not so. I estimate that the friend's Delphi installed some problematic third-party controls, resulting in the frequency error of Delphi. Try those controls?

Portability: Based on reality, look for future inprise is developing Delphi's Linux version, code to Kylix. Perhaps through Kylix, a Windows program written in a VCL architecture is possible to transfer to Linux. But this is just possible. Because it is not good to work in the current Inprise compatibility. Low versions of Delphi cannot use high versions of VCL components (which don't say it), and high versions of Delphi can't use low versions of VCL components. It's really this, I rarely see the software is compatible with the binary. If Windows 98 cannot run 95 programs, Windows 95 cannot run 3.x, Win 3.x cannot run the DOS program, do you still use Windows? If the Windows 95 program must be recompiled to run in 98, 98 will sell so good? "The Game Brothers" C Builder and Delphi can not use each other components, even the file name of the VCL library is different. So a component has a different version of these different versions of the FOR D1 / C3 / C5, and the upgrade of Delphi and C Builder versions may also increase. I hope that Inprise can solve the compatibility problem of the same brother. And Microsoft's VC has no such problem. The program of MFC 1.0 can also be compiled under VC6.0 without barrier.

Integrated interface: Macro and microscopic, the VC's integrated interface is not as good as Delphi. Delphi only one Object Inspector can take a pile of wizards of the VC, let alone, it also has Code Explorer, Todo List, etc. But from the small place, you can see the immature of Delphi. For example, the intelligence of the "Automatic Finish" function and the rating of the prompt is not as detailed as VC, and the response speed has no VC fast.

The MSDN belled in Visual C is a "developer's encyclopedia", huge information, convenient inquiry, which is more professional than Delphi. Many help items have source program demonstrations. Delphi's OpenTools is a full-length open system, developers can modify a lot of Borland's own features, say Delphi better from IDE's expansion.

Debug: See the truth

The debugging of Visual C and Delphi is very powerful, and it has single-step visual debugging, breakpoint tracking, runtime changing variables, and the mouse pointing can obtain variable values. The input and output of the DLL can also be easily managed, and the source code level debugging can be performed.

Relatively, Visual C can more conveniently see the change of variables, including the structure of the structure to be expanded into data tree, thus understanding the value of each variable, each step of debugging, changing variables will red, thus making debugging More convenient. In addition, the interior of Visual C is convenient than Delphi.

of course,

Delphi

There are also a lot of thoughtful things, such as when the thread is debugged.

Delphi

It is convenient to see changes in threads.

Visual C

Be you must pop up a mode dialog.

转载请注明原文地址:https://www.9cbs.com/read-441.html

New Post(0)