How to write modern Windows software in C++?
I am very interested in how modern Windows software is written in C++ nowadays. I asked my friend who had worked on Windows software and he told that last things he worked with were MFC and then WTL. He said that MFC is no longer anything modern but WTL is still used but he didn't know much more. He also said that WTL wasn't that modern and before that he programmed in pure Windows API.
How does one write software for Windows Vista or Windows 7? Do you still use WTL? What about MFC and pure Windows API? Or are there other libraries now?
I don't know much about it, but have C# or other .NET la开发者_如何学Pythonnguages replaced C++ in writing modern Windows software?
From what I've seen over the past several years:
WTL is on a lifeline. Abandoned by Microsoft, picked up by fans and there were several very dedicated followers. Very clean, but the learning curve is steep and the fan base dwindling. The Yahoo group is not very active. I can't recommend it.
MFC got another lease on life when MSFT released the feature pack. Rather extensive and a bit un-MFC-ish, it has strong support for skinning, docking layouts and ribbons. I thought it was going to be wildly popular but never did see a lot of devs jumping on it. MSDN forum questions have been sparse. If you have an existing MFC codebase then definitely take a look. Another MFC refresh for VS2010 with Win7 features added, it does stay the company's base UI solution.
wxWidgets is still around. No personal experience, but Lord, the few practitioners I've heard from are bitching up a storm. Real bitter stuff too.
Qt has been around for quite a while but picked up stream considerably, especially in the last year. Whomever uses it really likes it. It is moving beyond the confines of a UI class library as well, their users are looking actively for solutions to common programming tasks that start with the letter Q. That's a powerful vote of confidence.
But if you are on a Microsoft stack, none of these class libraries is where the real UI development is at. WPF is the elephant in the room, it's capabilities are a hundred miles beyond what's listed above. Its ability to break device and paradigm boundaries are powerful, writing code that runs on a desktop as well as a web browser as well as a phone is hard to beat. But C++ is not part of that.
WTL, Qt, wxWidgets are used pretty common.
They all allow rapid GUI development and are pretty versatile (third option, to my mind, takes more time to get used to). Second and third options are really cool because they're cross-platform.
Writing windows in pure WinAPI is extremely oldschool but sometimes could be entertaining.
C#
approach to building windows is even more rapid compared to previous options, but is a bit less flexible.
Have a look at Qt -- you may like it. Unless of course you prefer a something non-portable version. But even if you don't plan to build on OS X, Linux, phones, ... the Qt framework is well written, well documented and just works. The SDK now includes a nice IDE (Qt Creator) too.
WTL everytime if your main platform is Windows. Google Chrome uses it, Spotify use it. Its the most productive, flexible, isn't a resource hog. By flexible I mean you can use it with pure Win32 API code / other C++ code without too much difficulty.
For more WTL information: collection of WTL links
After evaluating i came to the situation where pure Win32 or WTL is the only way to write modern style win apps which are not WRT based.
The new look is the main point. MFC looks terrible on Win8 and Win10 especially with all this Feature Pack eye candy. Pure MFC is good but fat and the view-model part is just outrages terrible and i just like WTL more. But it's undocumented and this is so bad and scary.
WxWidgets is an ugly toy.
QT is not an alternative anymore too. They focus too much on mobile and appframework. And if you go MacOSX you can't use QT at all (yes it will run but it will make you vomit about the UX).
WinRT is so restrictive and lacking features that you can't use it. And you can be sure that it will fail because nobody is using the WinStore or Windows on Tablets/Phones. So why bother.
WPF is ok if you think you user appreciates slow and fat apps. It looks nicer but all the eye candy is now not part of the UI design guidelines anymore and the feature set of the widgets is less then Win32 native widgets. Unbelievable but true. And i locks you into using unportable C# which is deprecated in my opinion because now performance matters again (because performance is energy, is life time).
Even Herb Sutter and other high ranking MS employees tell you that C++ is the future. And the next killer app is build on C++14 and Microsoft knows it.
In .NET (C#, VB.NET, ...), the cutting edge of GUI programming is WPF at the moment (replacing WinForms). Compiled code in .NET is actually CIL which is compiled into native code at runtime by the JIT. This has the advantage that you do not have to care about 64 or 32 bit target systems.
In C++, Qt seems a good solution as it is cleanly designed and provides a big bunch of services. What I dislike in Qt is its compile round trip, it is so slow, there is a moc compiler, the compiler, then link, it takes ages compared to C#/.NET to get the executable. On the other side you may encounter it even in embedded systems, what makes it interesting in such cases.
I would advice you to have at least a look C#/.NET and experiment with it before deciding.
精彩评论