How can I decide whether to use ATL, MFC, Win32 or CLR for a new C ++ project?

I am just starting my first C ++ project. I am using Visual Studio 2008 . It is a single-format Windows application that accesses multiple databases and initiates a WebSphere MQ transaction. I basically understand the differences between ATL, MFC, Win32 (I'm a bit foggy actually) and the CLR, but I'm at a loss as to how I should choose.

Is there one or more of them for backward compatibility?

Is CLR a bad idea ?

Any suggestions appreciated.

Edit: I chose C ++ for this project for reasons that I did not go into this post that are not completely technical. So, assuming C ++ is the only / best option I should choose?

+61
c ++ clr winapi mfc atl
May 04 '09 at 19:47
source share
5 answers

It depends on your needs.

Using the CLR will provide you with the most expressive set of libraries (the entire .NET platform) by limiting your executable file to the requirement to install the .NET Framework at run time, as well as restricting the use of Windows (however, all 4 of these technologies are just windows, so the platform’s limitation is, probably the least problematic).

However, the CLR requires using the C ++ / CLI extensions for the C ++ language, so you need to learn some additional language features to use this. This gives you a lot of β€œextra features,” such as access to .net libraries, complete garbage collection, etc.

ATL and MFC are slightly more difficult to solve. I would like to refer you to the MSDN page for a choice , to decide between them. The best part about ATL / MFC is that you do not need the .NET platform, but only VC / MFC runtimes must be installed for deployment.

Using Win32 directly provides the smallest executable files with the smallest dependencies, but works more on recording. You have the least support libraries, so you write more code.

+63
May 04 '09 at 19:53
source share

Win32 is a simple, easy way to do this. It is tiring, difficult to use and contains many small details that you need to remember, otherwise everything will not be so mysterious.

MFC is based on Win32 to provide you with an object-oriented way of building an application. This is not a replacement for Win32, but rather an improvement - it does a lot of work for you.

System.Windows.Forms (which I assume you mean by the CLR) is completely different, but bears a lot of similarities with MFC from its basic structure. This is by far the easiest to use, but requires the .NET platform, which may or may not be a hindrance in your case.

My recommendation: if you need to avoid .NET, then use MFC, otherwise use .NET (in fact, in this case I would use C #, since it is much easier to work with it).

+17
May 04 '09 at 19:58
source share

As for C ++, I would use WTL. This is easy, and you will have few (if any) dependencies, which will simplify shipping and installation. I find it very enjoyable when my application consists of a single EXE that will work on most versions of Windows, but it may not bother you.

If you decide to go .NET instead, then C # will almost certainly go.

More details in WTL here:

http://www.codeproject.com/KB/wtl/wtl4mfc1.aspx

+13
May 4 '09 at 19:58
source share

I would be very curious why you do this in C ++ at all. Based on your brief description, C # seems like a much more appropriate choice.

To figure it out a bit, look at the link you gave while describing the C ++ CLR. The most popular answers to questions (more precisely, in my opinion) that C ++ is suitable for "the kernel, games, high-performance and server applications" - none of them seem to describe what you are doing.

MFC, ATL, etc. will be supported in the sense that yes, you can compile your application in future versions of Visual Studio and run them in future versions of Windows. But they are not supported in the sense that there is not much new development in the API or language as in the CLR and C #.

+7
May 04 '09 at 19:51
source share

There is nothing wrong with the CLR. Like others, I suggest C #, but since you have reasons to stick with C ++, using the .NET framework is several thousand times easier than messing with ATL / MFC if you are not already familiar with them (IMO).

It might be worth mentioning that if you are using C ++ / CLR, you are not using C ++ at all. C ++ / CLR compiles in CIL in the same way as C #. I never used it myself, but I believe that its goal is to give you the opportunity to compile outdated code and make it available for new .NET code, rather than allowing the new code to work with old C ++ executable files. There are other methods for invoking native code from .NET, which you should probably learn.

+3
May 04 '09 at 20:28
source share



All Articles