Coffeehouse Post

Single Post Permalink

View Thread: Any C++ guys out there?
  • User profile image

    I don't think C++ is dying...I can't remember the source, probably Stroustup's site...but I think recent data shows that C++ use is still growing. C# does not trump C++ on features or coolness. It's just a different tool for a different sort of task.

    My mantra from the time I started programming was to avoid languages that didn't let me at the hardware. C++ is one of the few relatively higher-level languages which can be used to write a whole operating system. C# and Java fail miserably at that. C++ is also amazingly elegant as a multi-paradigm language with its focus on type creation. It really is very different from languages like C# and Java in this respect. Further, although C# lets you forget about memory, resource management is a total pain. Because there are no true destructors, you have to write contortions in your code just to free up file handles, semaphores, etc. You'll have serious problems if your code doesn't do it properly, as the garbage collection for those objects is very slow (see the documentation on dispose). I find the C++ model easier to deal with, though you do have to think a lot more about resource ownership. (The reason is that an object can free itself up in the destructor. In C# you have to have using blocks all over, making it the caller's job to deal with it.) C++ also lets you write very smart customized memory allocators that are very fast. And if you compare C# generics and C++ templates in depth, you'll see that they are not at all the same thing.

    That being said, C# and Java are great for many types of applications. They have built-in security features and an amazingly rich library. They are simple enough to whip out some decent applications in a hurry. In general, I say choose the right tool for the job; no single language is perfect for everything. We use both.

    I would not be surprised if new Windows APIs appeared only in managed code. After Win32 Microsoft started making some COM-only APIs. This is Microsoft's next evolution. (From what I have seen so far, though, under every new .Net API is a C/C++, COM, or Win32 API.) I think Microsoft likes to keep us developers scrambling to keep up with all their new APIs to do the same old stuff. It certainly gives them an edge.

    Fortunately I think there is good evidence that Microsoft is still investing heavily in C++. VC++7 includes new things like ATL Server for web services, better ISO compliance, and managed code integration. Integrating managed code was a huge task; I don't think Microsoft would have done it if C++ was "dying".

    Unfortunately, Microsoft likely has MFC in maintenance mode, will never officially support Windows Template Library, and wants us to use managed code for the GUI even in C++.