Answer: "talking about Delphi vs VC ++" -- uncover ulterior motives and lies

Source: Internet
Author: User

A: Let's talk about Delphi vs VC ++.
---- Uncover ulterior motives for lies

Recently, I read "talking about Delphi vs VC ++" in CSDN, which was sorted by Mr. Jiang Tao and recommended as "wonderful ". We hold on to the concept of Bjarne. We don't want to get involved in the competition between the advantages and disadvantages of programming languages, but we have to say a few words in an dishonest learning attitude.

As a habit of Language Comparison in the industry, the author's attitude of course is "unbiased" at the beginning. However, as always, the fact is disappointing: the "Six Classics note me" that people in the academic community know once again opens a curtain show in the IT industry. "Six Classics note me" is already a mouse in the academic world, but in the software industry, this kind of behavior that will distort or misinterpret the original materials to cater to their own views has ushered in a colorful voice, which is surprising.

Let's get down to the truth. Let's invite friends and I to take a look at the loss of the author's learning methods.

I. Compiler
The compiler, as a language program reality, often plays a decisive role in the success or failure of the language itself. Especially popular compilers are often equivalent to the language itself in people's minds and become synonymous with the language. Naturally, "repeat" compares the compilers of Delphi and VC with data in detail. After all, "borland's compiler is the best.
However, is the detailed data of the author really credible? Let's take a look at the author's statement on the code generation length:

"In fact, delphi/c ++ builder generates smaller programs than vc ++ in the case of dynamic or static connections. For example, select new in delphi/c ++ builder... | projects | mdi application, which uses the mdi app wizard in vc ++. The generated program functions are very similar. The comparison result is as follows:
(Delphi enables optimization, c ++ builder uses the maximum speed optimization, and vc ++ 5 uses the minimum code optimization)
Delphi 3 delphi 5 c ++ builder 5 vc ++ 5
Dynamic link 21 k 35 k 44 k 70 k
Static link 253 K 398 K 467 K 490 K"

What is the result of my test ??

Minimum vc6.0 code optimization: (no documentation/view support) dynamic: 24 K
Maximum Speed Optimization: (no documentation/view support) dynamic: 24 K
Minimum code optimization: (no documentation/view support) static: 256 K
Maximum Speed Optimization: (no documentation/view support) static: 256 K
Minimum code optimization: (supported by documents/views) dynamic: 28 K
Maximum Speed Optimization: (supported by documents/views) dynamic: 32 K
Minimum code optimization: (supported by documents/views) static: 288 KB
Maximum Speed Optimization: (supported by documents/views) static: 292 K

We can see that the data listed in "repeat" is inaccurate. Naturally, some may point out that this may be the version difference between VC5 and VC6. I don't have VC5, but I can tell you that due to the influence of the size of the MFC Library itself, the code length of static connection version 5.0 should be larger than that of version 6.0. Dynamic connections, even if we consider the huge progress of optimization technology, will not suffer from exponential reduction even on the same order of magnitude.
Let's take a look at the quality of code generation in "again. Here, the author gives a comparison of the three compilers:

(1) object pascal:
Procedure foo;
Var
I, j: integer;
Begin
For I: = 0 to 15 do j: = j + I;
End;
(2) c ++
Void foo (void)
{
Int I, j;
For (I = 0; I <16; I ++) j = j + I;
}

Code generated by delphi 3 (enabling optimization): number of bytes in the clock cycle
0020.aa9 33c0 xor eax, eax 1
00347aab 40 inc eax 1
00w.aac 83f810 cmp eax, 0x10 1
00347aaf 75fa jnz-0x06 0 (parallel)
-----------------
8 3
Code generated by c ++ builder 5 (Maximum Speed Optimization ):
00401535 33c0 xor eax, eax 1
00401537 40 inc eax 1
00401538 83f810 cmp eax, 0x10 1
0040153b 7cfa jl-0x06 0 (parallel)
-----------------
8 3

Code generated by visual c ++ 5 (Maximum Speed Optimization ):
27: for (I = 0; I <16; I ++)
00401205 mov ecx, dowrd ptr [j] 1
00401208 xor eax, eax 0 (parallel)
28 :{
29: j = j + I;
0040120a add ecx, eax 1
0040120c inc eax 1
0040120d cmp eax, 10 h 1
00401210 jl foo (0x0040120a) + 0ah 0 (parallel)
00401212 mov dword ptr [j], ecx 0/1 (depending on the branch prediction of the previous command)
30 :};
-----------------
16 4.2 (assuming branch prediction accuracy is 80%)

The minimum code optimization of vc ++ 5 also has 11 bytes:
27: for (I = 0; I <16; I ++)
00401205 xor eax, eax 1
28 :{
29: j = j + I;
00401207 add dword ptr [j], eax 1
0040120a inc eax 1
0040120b cmp eax, 10 h 1
0040121e jl foo (0x00401207) + 7 0 (parallel)
30 :};
-----------------
11 4

I am not familiar with assembly language, but it can be seen that the codes generated by Delphi listed by the author are faster than VC by more than 33%. However, test equivalence? From the Assembly Statements listed in this article, we can see that the VC compiler is in Debug mode when the code is generated. As we all know, the relationship between the language and the generated code must be ensured during debugging, so a large number of optimization options will not work. Due to my personal ability, I cannot provide the assembly code in the Release mode. I hope my friends who are familiar with the compilation can complete the code.
As for the 8's code efficiency challenge, I never believe in the evaluation of Delphi on the Delphi site, just as I don't believe in the evaluation of VC on the VC site. What about you?

Ii. Language Features
Undoubtedly, language features are the essence of programming languages. Choosing a language, or not a language, whether the language has the features you need may be the most powerful reason. Repeat compares the following aspects:
(1) preprocessing, macros, And. H files
Let's take a look at what "youshu" says:

"Object pascal does not support preprocessing, which is not required. Compilers that cannot directly compile the source code must support the pre-processor"
"Macro and. h should be said to be Spam features, but they are reserved only for compatibility considerations. The ansi/iso c/c ++ specification clearly recommends that you do not use macro and. h, instead, use constant definitions and functions in your program ". "

This is true. preprocessing is indeed outdated. The first in Objective C ++ is: "Prefer const and inline to # define ". However, I have a reserved attitude towards. H files. After all, separating declarations and implementations is a more flexible programming style.

(2) Set and subfield type

"C ++ does not support the native types of these objects pascal (which can be directly recognized by the compiler ). But it can be simulated using classes. After all, the object structure of c ++ is the most complex and flexible (except ada ). However, performance is compromised. "

(3) Enumeration type

"Object pascal does not support Specifying values for each enumeration element. "

(4) array

"C/c ++ does not support the array of objects specified by pascal. The subscript can only start from 0. "

(5) Structure
"Object pascal does not support struct"

(6) String

"String processing is one of the strengths of object pascal"
"String/ansistring in c ++ is simulated by class, so performance ..."

For example (2) (3) (4) (5) (6), data types are involved. As we all know, the richness of Data Types determines the semantic expression ability of a language to a large extent. The native types of C ++ are not as rich as the object pascal, which is non-trivial. However, as the author said, C ++ has the most flexible secondary type mechanism, so its semantic expression capability is not limited.
(5) It is pointed out that "object pascal does not support struct ". In fact, in C ++, except for the default access permission, struct and Class are identical. Therefore, it should be regarded as the language component in object pascal. (2) (6) the efficiency problem is raised. It can be seen that the author of repeat does not understand the solution provided by STL that is similar to that provided by native types, even less can't understand the design concept of C ++ "only putting the core into the language, and the remainder is implemented using the class library. Naturally, some may ask, is there such a complicated design for C ++ that runs through such an idea? Well, that's because of the two higher priorities: "fully compatible with C" and "Integration of object-oriented and efficiency.

(7) Multi-Inheritance

"There is no doubt that object pascal does not support multiple inheritance, and it cannot be seen that borland has the intention to increase this feature (in fact, adding is a breeze ). Object pascal implements multiple inheritance through interfaces. "
"Do you really need multi-inheritance? I think most programmers, like me, have never used multi-inheritance (even vcl's powerful and flexible architecture does not use multi-inheritance at all ). "

Similarly, Objective C ++ has a pertinent comment on multi-inheritance: "Depending on who's doing the talking, multiple inheritance (MI) is either the product of divine inspiration or the manifest work of the dedevil. proponents hail it as essential to the natural modeling of real-world problems, while critics argue that it is slow, difficult to implement, and no more powerful than single inheritance. (according to different opinions from various groups, multi-inheritance (MI) is not the product of the holy inspiration, but the knot of the devil's wizards. Jing. Advocates cheered for the 'natural and essential modeling methods for the real world 'provided by them, while critics pointed out that it is too slow to implement, there is nothing more powerful than a single inheritance .) "

(8) object Template

"Object pascal does not support object templates. Because the object template is just a macro language implementation (the macro itself is not a c/c ++ language feature ). "

This is the unique comment of the author of repeat on the template mechanism. In my concept, the strong template Mechanism in C ++ is not just a few words. C ++ supports four programming modes: (1) process programming (2) object-based programming (similar to Ada) (3) Object-Oriented Programming (4) generic programming. Generic programming is implemented on the basis of the template mechanism and is widely used in STL.
Essentially, this is related to the semantic expression ability of the language. A language with a template mechanism can naturally express more than a language without such a mechanism. In particular, when combined with Runtime polymorphism, it can express the semantics that is hard to express simply object-oriented. The essence of the so-called parameter classes in UML is the abstraction of template classes.
Let's take a look at Java, the industry-leading pure object-oriented language. Although Bruce Eckel does not agree with the template mechanism in his famous think in java, the next version of Java will also have a generic mechanism similar to the template.
Note: In C ++, templates are classified into class templates and function templates, and there is no reference to "Object Templates.

(9) Heavy Load

"Object pascal supports function/process overloading and does not support Operator overloading. C ++ supports all. (Ps: I personally prefer that object pascal should add support for operator overloading )"

(10) bits and logical operations

"Object pascal and c/c ++ have no difference in this regard. "

(11) style

"In fact, this is an important reason I prefer to use delphi (for work reasons, I often use c ++ and assembly ). As some articles have said: "object pascal and c ++ are the same heavyweight language." It is really difficult to distinguish between objects. The difference is mainly in style. C ++ emphasizes flexibility, while object pascal focuses more on cleanliness and beauty. "

"Object pascal and c ++ are the same heavyweight languages "? This is a widely spread misunderstanding. Since the emergence of C ++, it has been widely supported by the industry. After becoming an ANSI/iso dual standard, it is more supported by various software and hardware platforms. It is undeniable that the pascal language is also widely used and becomes more
Mainstream development languages on Macintosh. But note that it is pascal, Not object pascal. The latter is only supported by the limited company on the limited platform. It cannot be said that C ++ is a heavyweight.
When I read the comparison between Java and C ++ in year 96, I was very impressed with the following words: "working with C ++ is like a chainsaw with a shell unmounted, powerful but insecure. "Well, good. Using C ++ requires a higher degree of discipline. This is the cost of C ++'s design philosophy of" giving programmers more control.

I often think of three phases of language learning:
(1) Learning grammar and semantics. How to Use the syntax? How do I express the specified semantics?
(2) internal implementation learning. How is the compiler implemented? How do I express the specified language components internally?
(3) experience in design concepts. When you enter this stage, you should find that each language has its own design philosophy. Why does C ++ have multiple inheritance than Delphi? Why does Java embed the Garbage Collector while C ++ is provided as a third-party class library? From the consideration and balance of language concepts, you should be able to give answers one by one.

3. Functions and other
The preceding comparison shows two basic elements of a language: the language itself and the compiler. 20 years ago, this was everything. Programmers had to start from scratch and stack their own code on the poor function library. But the introduction of framework has brought about a revolution. "I am far away from others, just because I am standing on the shoulders of giants." Newton's sentence can describe the role of framework in development.
Another major role of the revolution is the so-called IDE (integrated development environment ). Programmers of the old generation let their fingers jump on the keyboard, and the screen has a dazzling flip switch. Well, a "Finger Dance" on the keyboard ". However, this is an era of mouse dancing. The competition for development tools has been focused on the integration of framework and IDE. Oh, don't mention Java with me. It will compete with C # In the next step, and the focus should also be on the underlying framework.

(1) ease of use

"There is no doubt that Delphi has a huge advantage. You can leave it alone. "

(2) Applicability

"VC ++ can do almost any work allowed by hardware. You can also use Delphi. "

From the developer's perspective, Delphi's strong usability mainly comes from two aspects:
(1) rad development method. Rad is the most intuitive development. "Dancing with the mouse" does not know how many developers have been released. However, there is no white lunch in the world. Due to code fragmentation and small granularity of incremental development, full use of rad to develop large systems is always a challenge to software engineering capabilities.
(2) High-level encapsulation. As we all know, compared with the very thin encapsulation layer of MFC, VCL has a high encapsulation layer, so through VCL, programmers do not have to contact
Underlying details improve ease of use. This does not mean that Delphi loses the ability to perform underlying operations: a well-designed framework always provides a method to break through the proxy layer. However, after all, the broken-down agent layer is abnormal, and efficiency and convenience are often not considered by the designer.

(3) integrated development environment

(4) Database Support

(5) network functions

(6) component support

"In addition to the object pascal-based vcl/clx, delphi also supports com/dcom-based components (such as activex), and added the support of corba. Vc ++ only supports com/dcom-based components. "

The Development Library provided by a third party must be used when VC ++ develops the corba program.

(7) Application Framework/Design Philosophy

"Vcl is at least one generation ahead of mfc, which is not required to be mentioned. "

VCL is ahead of MFC, which is beyond doubt. In addition to the encapsulation of the underlying API, the evaluation of the framework is more important than the encapsulation of the message mechanism. How messages are transmitted between objects is the core of the framework and has a decisive impact on the object model of the entire framework. VCL is superior to MFC, and its essence is the "responsibility chain mechanism", which is superior to the "message ing mechanism" macro-implemented by MFC ". As for the encapsulation of the underlying API, you can also implement it as you wish.

(8) debugging

(9) running environment/System Requirements

(10) Product Quality/Stability

"Some articles refer to" good quality and high stability of vc ++ ". Is that true? Isn't the service pack of visual studio output to 4? What is a service pack? Isn't it bug fix + patch ?! "
"In the end, the quality of the program is good, and the running stability is unstable, mainly depends on the developer's level/responsibility. "

Karl Pope proposed in his scientific philosophy that a proposition can only be falsified and cannot be confirmed. When it comes to software engineering, the software can only be proved to have bugs, and it cannot prove that there are no bugs. In fact, software of such scale inevitably has a large number of hidden errors. The continuous service pack shows that debugging and debugging work is ongoing without interruption, which is more responsible than the policies of hunchbird.
Regardless of the quality of the class libraries and tools, the language selection and software quality also have an impact. Under the guidance of the "stability first" concept, a strong fault tolerance mechanism is generally provided, and the design of the language itself is also considered to prevent programmers from making mistakes. Removing pointers in Java implements the "stability first" concept.

(11) Help/Documentation

(12) international support

(13) application fields

"Vc ++ is widely used in the development of windows Device Drivers (after all, m $ windows) and some desktop applications (such as games. More delphi applications include databases, multi-layer structures, multimedia and internet development. "

In fact, the main user who uses VC ++ is in the communication field. In my personal opinion, VC is often positioned in the development of general-purpose software, and we need to try our best to be less refined. Delphi is used in the development of customized software (personal opinion only ).

(14) price

(15) downward compatibility

This is a problem avoided in repeat. In fact, Delphi is not doing well in this regard.

(16) Prospects

"Not for a few years, both of them disappear ". Of course, this is just a private whisper when I am excited.

First, let's look at Borland's market strategy. As a matter of fact, Delphi is in the middle of the market. No, I am not very talking about low-end VB and high-end VC, but powerful Java and new C #. Coincidentally, both of them support the RAD development method, have strong network features, and have optimized database support. Where is Delphi? Borland answered with Kylix:
"Provides cross-platform portability that gives full play to platform features ". Java provides platform independence, while C # gives full play to the platform features. From the perspective of it, Java cannot use the platform features. C # does not have cross-platform portability. The market space between the two is exhausted by Delphi.

Where will VC ++ go? Inevitably, the role of VC ++ will be shifted to the background, leaving the foreground desktop-> background services-> underlying support-> system development. This is the fate of C ++, which emphasizes efficiency.

4. Conclusion

"Delphi (actually borland products) has technical advantages. vc ++ (actually m $ products) also shares a considerable market share. "

This is a conclusion without conclusion. Well, aren't all the answers written in the analysis and description above?

I will not analyze the Appendix 5 of "repeat". After all, it is just a matter of low-cost emotions.

I am a VC user and have special feelings for C ++. However, I hope that the comments on "repeat" will not be too positive. I hope that all the articles I read in the future will face the facts and there will be no "Six Classics note me.

Ps: Let's talk about Delphi vs VC ++ http://www.csdn.net/develop/read_article.asp? Id = 5264

Touch me: dream_soft@263.net

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.