MFC sucks performance wise but it's great for Win32 GUI applications
I agree with Darwen that inheritance is a wonderful thing. But you have to keep in mind that every tool is built with a different purpose in mind. Each of which have their own limitations (including MFC) and their strengths. MFC has a ton of thread dependencies that make it a real pain to use in multi-threaded programming. This is because Microsuck decided to 2store information on a thread specific basis. In doing so they created problems with creating MFC objects in one thread and using them in another. And no I am not referring to just a simple synchronization issue. In some cases you simply cannot use a class in a thread outside of the one that instantiated it.
Moving back to STL, it was designed to be portable, light, and extremely fast! And it meets all of these requirements and then some. Place virtual destructors in STL would do nothing but hurt performance because the compiler would have to generate a V-table. In most cases this performance hit might not be substantial but it would hurt the design of STL.
As for the STD:: blah blah....that's just a ridiculous comment. If you've been developing in C++ for so long than you should be using namespaces in your own applications. They are very important in large scale development projects. Of course if all you do is work on Hello World, than I could understand why namespaces aren't so important to you.
I would like to suggest to anyone that doesn’t like STL, try building an application that uses “Cstring” and one that uses “std::string” to see which one performs better. You’ll understand what I mean if you just spend the time to look at other tools. MFC is great for some things but don’t use it to build a Windows NT service and expect to get a lot of performance out it. Besides, basing an opinion of a technology on the fact that you can’t inherit from it doesn’t make any sense at all. There are a lot of factors that should go into these kinds of comparisons.
To sum this all up…STL rocks! It’s fast…efficient…and very easy to use.
Microsoft's compiler sucks!
If you think Microsoft's code is written in some fashion to gain optimal speed from their compiler you are WAY WRONG!!! Actually, I can't even begin to tell you how wrong that statement is.
Take some advise and download Intel's C++ compiler and build an MFC, STL, and any other application that you like using their compiler. Than compare the performance between the two. You will find that Intel's compiler kicks the crap out of Microsoft's any day.
Microsoft makes a great IDE (Visual Studio) but they don't concentrate on the compiler to the extent that Intel does. Keep in mind the Intel C++ compiler is a plug-in for Visual Studio so you can install it and switch between the two compilers with ease.
Give it a try...I promise you will never want to return the Microsoft compiler again!
lack of balance in MFC vs STL thread
I am surprised at the lack of balance in this debate. MFC and STL were architected to meet different needs of differing communities of developers. Rather than debate which library is ‘better’, I suggest you review the strengths and weaknesses of each so that you’ll be able to identify and apply each in the proper context.
If you truly do not understand the tradeoffs (size, space, speed, flexibility, coupling, and cohesion) between subtype polymorphism (inheritance) and parametric polymorphism (templates) then I hope your impact on commercial systems is limited to “coloring inside the lines” of someone else’s design.
This is not a personal attack; simply an view honestly expressed. Like so many other domains – software engineering suffers from the tyranny of the majority. Our field is perceived by the quality of the ‘average’ product produced by the ‘average’ programmer and the quality of both of our averages is far to low.
As far as whether either MFC or STL is OO (or good OO), it simply doesn’t matter. OO is so 80’s and 90’s. What matters is generic, efficient (provably), and reusable software using all means provided to maximal achievement. Inheritance vs. Templates, Function Templates vs. Overloads, Members vs. Friends vs. Out-of-Bodies; there is no “one true way”. No single style or subset of a language is best for all occasions. If so, our languages would simply be smaller. Basic computability theory proves that for any algorithm there are an infinite number of result-equivalent implementations yet each has a unique signature in its path to a common result – meaning differences in size, space, speed, etc.
There will always be numerous ways to reach an end – whether in C++ or any other language. Programmers who grasp the language understand that each way is necessary and not in fact duplicative.
Re: lack of balance in MFC vs STL thread
Quote:
Originally posted by mclark
I am surprised at the lack of balance in this debate.
Well, as I understand this thread, it is a comparison of MFC
containers and STL (or STC if you like). So where is the
lack of balance? Unless you mean that Darwin is off-balance in
his dogmatic refusal to accept the truth.
Quote:
MFC and STL were architected to meet different needs of differing communities of developers. Rather than debate which library is ‘better’, I suggest you review the strengths and weaknesses of each so that you’ll be able to identify and apply each in the proper context.
Well why don't you start this review? To me MFC is a GUI library that
wraps the Win32 API and adds some extensions like DOC/VIEW.
I have not been pleasantly surprised by any of the lower level
tools and try to avoid them whenever possible, either by writing my own wrappers or turning to boost or the standard.
So what community is MFC geared for? The key word here is GUI.
IMO It is for allowing people to churn out a user interface quickly
and without really knowing what is going on.
At the lower levels of my program I want things to be small and
task specific and I want control. I don't want the "evil MFC framework"
playing any role in my objects to latter come back and bite me on the a_s_s.
Quote:
If you truly do not understand the tradeoffs (size, space, speed, flexibility, coupling, and cohesion) between subtype polymorphism (inheritance) and parametric polymorphism (templates) then I hope your impact on commercial systems is limited to “coloring inside the lines” of someone else’s design.
Again, how about some details. I am not trying to be rude, it is
just that it would be nice to learn something. I don't disagree
with anything you said.
I don't know how to quite express my thoughts here. I can't
really talk about performance without just quoting someone else, so I will talk about semantics. To me a container
like a vector is a basic object. You don't inherit from it to extend
its capabilities; you write template classes which contain it or
write algorithms to manipulate it. Forgive me if everyone disagrees with this, it is just a point of view I have come to.
To me template programming represents a higher level of
abstraction than inheritance. And adding levels of abstraction
allows one to say and accomplish more with less. Don't get me
wrong, inheritance definitely has its place, but to rigidly demand it
in all situations is silly. A vector is a vector. The usual reason to want to inherit from it is, for example, to have a vector that does this or
that. I believe the proper way to think is that I have a vector that I perform this or that on, not a vector that does this or that.
Quote:
As far as whether either MFC or STL is OO (or good OO), it simply doesn’t matter. OO is so 80’s and 90’s.
It is so 90's to say it is so 80's and 90's:)