Qt vs MFC
Philippe Fremy writes: "I have just published and translated into English a comparison between Qt programming and MFC programming, which was written by Pascal Audoux (a fellow coworker). I am interested in feedback and would love to add quotes from developers that have used both toolkits." Here is the English version ("Qt vs MFC") as well as the French one ("Qt contre MFC").
[ Philippe Fremy speaking ]
> It's fast, and it doesn't require a temp variable.
Yeah, great. But I better have them fix their bugs, their crashes and their memory leaks than spare a temp variable. Besides, the code appears in a function that is not optimised at all.
You are focusing on the one the example I gave. Does a 500 lines method looks acceptable to you ? Do you think this is also to spare the cost of function calls that they use so many of them ? Or that having private members declared public is good ?
Their code is crap. It is good in the sense that it makes it a lot easier to build powerful GUI applications and that it works most of the time. But it is crap when you read it.
> Look at QT's code, and you'll see the same thing.
The big difference is that in three years of Qt programming, I had just to look once at Qt's code to be sure I understood the doc properly. With Codejock, there are stuff that are simply not documented, and stuff that you can not use if you do not look at the source code.
> Acknowledging MFC's strong points is important.
I am sorry, I haven't ran into them, except for the fact that it comes free with Visual Studio. But I'll add any if you have one to propose.
I recognised we are not good writers. And we made one mistake in this article. We did not point out that we did in no way pretend to be objective. We were just sharing our experience of Qt programming and MFC programming. I'll add a disclaimer in that direction tonight.
Qt wraps completely the win32 api, and then relies on its own model. So it can and in fact, it did clean things up. And they rely on very low win32 calls, where most of the problems do not appear.
.NET
CodeJock integrates with MFC, so it can not get rid of many of MFC pitfall. And it is not a very well engineered product.
> you go from EnableWindow(window, verb) to window->Enable(verb)
If it was just that, that would not be a problem. Unfortunately, many MFC calls are usually more complicated, with obsolete arguments and strange naming.
You know when using it that the product is old and that they have tried to improve it over the time. Now, they have dumped it for
a ^= b ^= a ^= b;
If you don't recognize this, you probably need to go back to school. It's fast, and it doesn't require a temp variable.
Bull.
It's an overly clever hack that doesn't belong in a professional product. Why? Four reasons:
The "comparison" article is poor at best, but in this aspect it is 100% correct. XOR-swapping is a cool hack but has no redeeming values other than its coolness, and cleverness for its own sake has no place in professional code.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
I don't know why everyone is claiming MFC is no longer in the picture after .Net. It's like claiming Newspaper was dead after TV came out. Here is an excerpt from MSDN:
.NET, MFC and C++ developers may be feeling left out. But don't worry--with the upcoming release of Visual Studio .NET, not only do developers using Visual C++® get a brand new IDE with tight integration for server-side development and a much improved C++ compiler, MFC and ATL have also received significant new features. The clear message is that MFC continues to be a great framework for developing sophisticated, rich client applications for all Windows® platforms. In this article, we'll provide you with a survey of the new features that you can use in your MFC applications.
It has been three years since the last major update to MFC and ATL. With all the press on Microsoft®
There's a new MFC DLL (MFC70.DLL) that is no longer backward binary-compatible with MFC42.DLL, but your source is still compatible (although message maps have been made more type-safe, so that may break some code).
MFC and ATL are much better integrated, and common classes such as CString are now shared between the two libraries.
Header files are synchronized with the latest Platform SDK, supporting UI features in Windows 2000 and Windows XP such as themes and manifest resources, Active Accessibility®, and new common dialog boxes.
Many new UI classes have been added, including support for using DHTML in dialog boxes and enhanced bitmap support with CImage.
New utility classes can be used in both MFC and ATL applications, such as regular expressions, performance counters support, and security.
Now there's support for consuming Web Services in MFC applications and writing Web Services and applications with ATL Server classes.
High-performance access to databases has never been easier using the new OLE DB attributes and classes.
STL has been updated.
Maybe you've been lucky. Who knows? The fact remains that there are demonstrated problems that can occur when using COW strings in a multithreaded C++ system, and further, the advantages of using such a design are mostly illusory anyway. It seemed like a good idea at the time, but on reflection, it turned out not to be. (BTW, I have watched an application fall over for no good reason because its string library wasn't multithread-safe when it should have been, and I've watched the development team waste several man-days of time trying to find the bug in their code -- which wasn't.)
I don't think so. I mean a full-fledged immutable string class that supports the usual look-up and combination operations without the mutating ones, and a clean interface to convert between such a class and a vanilla QString. AFAICS, that's a whole world away from QConstString.
In simple cases, I agree, an automatic layout can be very helpful. OTOH, on a program I used to work on, extensive used was made of tabbed dialogs. The layouts of most of them were fixed across all of the tabs, so that similar controls didn't jump around irritatingly as you flipped from tab to tab. I don't know if Qt's automatic layout system would handle that, but certainly no other one I've ever seen does. Automatic layout is simply not the best answer to everything, which the article seemed to be suggesting.
With all due respect, if you think a simple translation mechanism like that is all there is to i18n/l10n, I can't believe you've ever worked on a large-scale multi-lingual application. There are other locale-related formatting issues (date/time, currency, etc). There are languages where routine system calls don't work on some strings (try a toupper on the German word Strasse, and then try the same on the same word written with a Schaffes s, and then compare them for equality). In Japan, most machines speak MBCS, not Unicode, so you need an effective means of converting between them, preferably as soon as the MBCS enters your program and just before it leaves so you can at least use Unicode internally. Some languages read right-to-left, or top-to-bottom, or even more devious variations, and you have to adapt your UI to cope with this, particularly when laying out dialog boxes and such. It is not as simple as a tr() function. (I'm not saying Qt couldn't cope with many of these issues, just that the emphasis placed on the tr() function by the article is overstated.)
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.