views:

347

answers:

6

I've never been a big fan of MFC, but that's not really the point. I read that Microsoft is due to release a new version of MFC in 2010 and it really struck me as odd - I thought MFC was dead (no ill intention, I really did).

Is is MFC used for new developments? If so, whats the benefit? I couldn't imagine it having any benefit over something such as C# (or even just c++ using Win32 APIs for that matter).

+1  A: 

I did a project last year based on MFC. I'm not sure why MFC was chosen, but it was adequate for making a virtual 3D graphic user interface—a building management security system—with 10 frame per second refresh rate run efficiently on win32-based PCs dating back to the mid-1990s. The executable (which requires only core win32 system DLLs) is less than 400K—not an easy accomplishment with modern tools.

wallyk
So, development for "legacy" systems? (I'm not being critical, I like legacy systems). My problem is that the MFC DLL's were HUGE (for their time) and quite in inefficient. So if speed or size are a concern why not just stick with the Win32APIs?
NTDLS
Because win32 is a huge setback in development time and you'll end up writing wrappers to make it more OO anyway. MFC's dlls aren't that huge, and if it's really an issues you can still link statically.
Roel
+1  A: 

There are advantages to staying away from managed code (maybe you're writing a driver UI, or doing COM).

That and there's tons of MFC code out there. Maybe you work for Company X, and need to use one of the zillion DLLs they've been writing over the last dozen years.

Seth
Agreed! I'm an old-school fan of unmanaged code - but I'm not sure if you can write drivers using MFC (I'm not not saying one can't, I just don't beleive one can. Certainly not a kernel-mode driver).
NTDLS
I meant driver UI's (like a "Printer Dialog" or something). Coding up dialog boxes in MFC is *really* fast.
Seth
I'm much more accustom to creating C++ Win32 application using a basic resource editor and a WinProc callback - which for me is much faster. Subjective, yes, but I personally see little appeal in using MFC for such applications. This doesnt make me right by any means.
NTDLS
Of course writing something without MFC is slower *if one doesn't know MFC*. Writing the same application with MFC is much faster than writing the equivalent in win32, given a competent programmer.
Roel
+4  A: 

MFC has been updated with every release of Visual Studio. It just isn't the headline feature item.

As for new development, yes. It is still used and will continue to be so (even though I, like you, prefer not to). Many organizations made the technology decision years ago and have no reason to change.

I do think you are talking about well-established shops though, folks with more interest in maintaining / enhancing what has been written rather than stay on the cutting edge.

Shaun
+3  A: 

There is a ton of code out there using MFC. I see these questions all the time is this still used is that still used the answer is yes. I work in a very large origination which still employees hundreds of people to write cobol. If it has ever been used in the enterprise it will continue to be used until there is no more hardware to support it, then some company will pay someone to write an emulator so that the old code will still work.

The navy still uses ships with computers with magnetic cores for memory and I'm sure they have people to work on them. Technology once created can never not be supported. its a bit of the case of Deus ex machina where large organizations aren't completely sure what their system do and have such an overriding sense of fear of brining the enterprise to its knees they have no desire to try out you new fangled technologies(BTW we pay IBM for best effort support on OS2).

Also mfc is a perfectly acceptable solution for windows development given it is an object model which wraps the System API which is pretty much all that most people get out of .net.

rerun
+3  A: 

MFC is still used for some new development, and a lot of maintenance development (including inside of Microsoft).

While it can be minutely slower than using the Win32 API directly, the performance loss really is tiny -- rarely as much as a whole percent. Using .NET, the performance loss is considerably greater (in my testing, rarely less than 10%, with 20-30% being typical, and higher still for heavy computation. Just for example, I have a program that does Eigenvector/Eigenvalue computation on fairly large arrays. My original version using C++ and MFC runs one test case in just under a minute on our standard test machine. Some of my coworkers decided it would be cool to re-implement it in C#. Their version takes almost three minutes on the same machine (quad core, 16-gigs of RAM, so no, not "legacy" hardware). I'll admit I haven't looked at their code too closely, so maybe it could be improved, but they're decent coders so a 3:1 improvement strikes me as unlikely.

With MFC, it's also easy to bypass the framework and use the Win32 API directly when/if you want to. With .NET, you can use P/Invoke for that, but it's quite painful by comparison.

Jerry Coffin
How much of that is due to the GUI though? Presumably you're using something like Intel MKL for the math in both cases, so what's actually causing the difference?
Pete Kirkham
@Pete:No, this particular program uses no outside code in any of the critical paths. If you'll pardon my sounding a tad conceited, Intel's programmers are good at optimizing -- but I'm better. More seriously, a lot of Intel's optimizations (by chance or otherwise) do quite poorly on AMD processors, which was unacceptable for this code.
Jerry Coffin
+2  A: 

The release of the MFC Feature Pack (one or two years ago, iirc) was the biggest extension of MFC since around 10 years and it gave quite a new boost to MFC development. I guess a lot of companies decided to maintain their legacy applications, push them forward and delevelop new applications on its basis.

For me (as someone who has to maintain a large MFC application) the bigger problem is the decreasing development and support of (Microsoft and third-party) components rather than MFC itself. For instance is porting to 64bit not easy if a lot of old and unsupported pure 32bit Active-X components are assembled in the application.

Slauma