Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I hear about modern C++ popularity and some talks about migrating back to C++ from C# or other C-like languages.

I know about C++11 features but I would like to hear your experiences, especially from developers who migrated from C# to C++.

More importantly, does Microsoft push developers to use C++? If yes, why?

share|improve this question

closed as not constructive by Giorgio, MichaelT, Martijn Pieters, Oleksi, Kilian Foth Mar 19 '13 at 10:15

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

13  
I think C++ has always been a more widely used language because it's more well established and easily portable than C#. I don't think it's replacing C#. For windows-based business applications, C# is still going to be in heavy demand as an easy-to-get-stuff-done-in language. C++ never really went away. It just had a sort of resurgence recently. –  KChaloux Oct 31 '12 at 13:58
2  
I hope not. Java and C# have been boons to developers and they are still evolving. –  Jesse C. Slicer Oct 31 '12 at 14:00
4  
Both C++ and C# are just tools: pick the best one for the particular job. e.g. if you want to write cross-platform code, you may want to use C++; if you want small apps that don't require .NET runtime installation you may want to use C++ (with CRT statically linked); if you want to develop some GUI tool for Windows in a RAD way, you may want to use C# and WinForms; etc. –  Mr.C64 Oct 31 '12 at 14:15
5  
It's a good question, maybe needs some rewording. It is not another language A vs. language B. Rather, it is specifically what is Microsoft's positions, why did it change and where are they going because the reality is that MS is big enough that when they exert influence at least smaller mountains do tend to move. And yes in this case, they are definitely influencing. –  DXM Oct 31 '12 at 15:13
9  
Let's please keep it civil everyone. Rudeness will not be tolerated. –  maple_shaft Nov 2 '12 at 14:04
show 7 more comments

8 Answers 8

up vote 70 down vote accepted

Yes, your suspicions are correct. Microsoft is pushing C++ to come back and become more popular.

I can't find it now, but a while ago I saw a presentation by one of Microsoft big guys and the whole thing was geared towards developers and was about roll out of Windows 8 and especially WinRT (the replacement for .NET framework as well as Win32 API).

He had a timeline that he explained how various pressures were affecting what technology was popular at certain times. So at first people wanted speed so they all coded in C/C++ (two separate languages). As the hardware got faster, the focus moved away from speed of execution and more towards speed of development, so higher level languages became much more popular.

However, now the focus is becoming more towards mobile and ARM-based computers (Windows 8 is first Windows release to be compiled for ARM) and many believe they will become much more popular and for some will completely replace the desktop. So the focus (at least in Microsoft's eyes) is back on C++ because now we care about battery life. Higher level code = more instructions = more juice required.

To support this transition back to C++, they've introduced a completely new Windows 8 programming API, called WinRT (last I checked, that was the name anyway). This API follows the theme of .NET Framework in the scope of functionality it provides but it will be available to anyone coding in C++ (via COM interfaces), in C# or even in Javascript for those that wish to write HTML 5/Javascript apps. They are also bringing XAML (technology used in WPF, their newest UI framework) to be available in C++ as well.

So to me that kind of indicates that there's definitely more focus on C++ at Microsoft than there was in the past.

UPDATE #1:

Since I just got a 'nice answer' badge for this, I thought maybe I should come back and a) clarify few things and b) make the fact-checking police happy because as we all know on technology forums anything inaccurate could result in wars that last for years.

  1. WinRT is not a replacement for .NET framework, but it is yet another alternative that MS Windows developers now have and MS is strongly pushing people to go in that direction. It appears (please hold your flames if this is not 100% accurate) that WinRT was primarily targeted for Modern UI apps although regular desktop apps should be able to take advantage of it as well. Having said this, MS is strongly pushing for people to switch to writing a) modern UI apps and b) start using WinRT so as the balance shifts percentage of people using .NET framework will most likely go down.

  2. C++ will NEVER replace higher level languages such as C# or python. Just like those languages will NEVER replace C++. This was probably the most controversial part of OP's question. But it is all about the balance and the facts are that:

    • C++ community (with MS being large part of it) is pushing for a strong comeback to position C++ as a good language for low-powered devices, whose market share has been going up like crazy lately. If you do not believe me, search for "GoingNative" series of talks that began last year.
    • With all the effort and influence from Microsoft, C++ usage will definitely go up, while C# might drop some what. This is what MS is pushing for and as I said in the comments above, when MS puts their capital behind an idea, they do shift large portion of the industry. I will probably get a response from some guy who will argue, "what industry, I've always been on Linux" and to that my only response is, wake up! Yes, there are other OSs out there but majority of desktop market, both consumer and business at the moment is Windows and any serious developer who wishes to maximize the value of his time would be very silly not to target that chunk of the desktop market.

So in conclusion: Yes, MS is pushing for C++ to come back so most likely its popularity will increase. No, C++ will never replace C#.

Update #2:

I don't know why but technical community tends to see things in very absolute black/white terms when the reality is full of shades of gray. This is a response to several new comments that were added to this post:

  1. .NET framework will not go away any time soon (or ever). Just about every technology that windows had since 90's is still around in some form or fashion. So for those that are so attached to .NET framework: a) don't worry about it disappearing and b) stop arguing in its favor as if your life depended on it, your API is safe.

  2. WinRT does reimplement a lot of functionality that in the past was provided by Win32 and .NET framework APIs. People who want that functionality will have a choice if they want to use WinRT, .NET framework, or continue with Win32 API (that's not dead either). If WinRT doesn't support easy creation of web applications today, there's a very good chance it will support them in the future.

The position that Microsoft announced is that WinRT is a large framework which gave Microsoft a chance to start with a clean slate and built an API using lessons learned in Win32 API and .NET framework itself. I did try looking for that video, and still can't find it, but one of the things the speaker mentioned is that there are certain areas of .NET framework which could have been defined better/simpler/cleaner and WinRT exposes that same functionality in that new cleaner interface.

share|improve this answer
5  
Was it Herb Sutter's talk at C++ and beyond, titled "Why C++?" There's a video of it on Channel 9, although I'm having trouble accessing it at the moment, probably because Redmond is hosting a huge streaming event. Your logic makes sense, but these kinds of statements really need to be backed up with some references, as this would represent a major strategic shift for Microsoft and anyone else who develops software with Microsoft's products. –  Robert Harvey Oct 31 '12 at 15:19
13  
WinRT is not replacement for .NET. Keep your facts in check please. –  Euphoric Oct 31 '12 at 21:27
3  
@Euphoric: In other words .NET framework was never replacement for Win32 API. At the same time, when C# came out many people switched over and forgot all about making C-style function calls into windows DLLs. MS is pushing for same switch now. So yeah, .NET framework will continue to exist under the hood of WinRT and sure you can still use .NET framework, but MS is pushing for people to switch to the new framework. –  DXM Oct 31 '12 at 22:13
18  
@gbjbaanb - This is 100% false. First ALL .NET ever was was always a very nice wrapper for Win32 library. Second there are only minor differences between the Full .NET Profile and 'WinRT' .NET Profile, the major differences, are a great deal of stuff that was poorly implemented 10-15 years ago were removed, and replaced with better designed code. Until they get rid of Win32 library all together .NET is here to stay. Your comment shows a COMPLETE and TOTAL lack of knowlege with regards to .NET and C# language itself. –  Ramhound Nov 2 '12 at 13:41
6  
Not to mention that for Web applications, .NET is great. If it were ever a 'replacement', it'd be for desktop apps, and not Web applications. –  George Stocker Nov 2 '12 at 15:19
show 13 more comments

It might just be me, but, I see much more plain C usage than C++.

The fact that C++ has swallowed plain C whole makes it hard to infer who is using what.

But there are vastly more C open source projects than C++.

My view is if you need close to the metal speed use C. If you need flexibility and manageability with reasonable performance use C# or Java. If you want a clean design done quickly use Python, Scala, Groovy or any of a number of fully featured languages.

share|improve this answer
add comment

c++ is not replacing c#. Let us look into where c++ language is used. It is used when there is need for high performance, for writing middleware libraries, low level access, and for writing code for resource constrained devices. Though you can use c# for some of these c++ is more suited for these. Microsoft's push for c++ is highly related its big push into the mobile space. Nobody will ask you to write your next web app in c++. But with Qt, the productivity argument cannot made against c++. But I think a lot of people are not familiar with Qt.

share|improve this answer
    
C++ is still heavily used in non-vertical commercial Windows software development. –  bit-twiddler Mar 18 '13 at 18:26
add comment

No, C++ can't replace C# because all the non-Direct3D Windows Phone 8 apps must be developed with C#. You can't develop and publish applications to wp8 app store just by using C++ or HTML5/Javascript. And as long as Microsoft doesn't remove this restriction, C++ isn't replacing anything. As a result, I am sure very few people will develop for WP8. Poor Nokia, losing one more time.

Here is the excerpt from microsoft dev center:

Windows Phone 8 doesn’t support the XAML UI with C++ code-behind app model that is supported for Windows Store apps.

yet another:

Does this mean that I cannot use C++ with XAML to develop an app on Windows PHone 8, am I restricted to use C# + XAML?

That is correct. XAML can only be used with C#. C++ can be used for a WinRT component used by the C# project.

Even Microsoft MVPs claim that this rumor is a deliberate misinformation made by Microsoft himself:

I love what Microsoft is doing with WinRT and Windows Phone 8, but I wish they wouldn't oversell some of it as it will just frustrate users once they learn the completely truth of the matter.

And this deliberate wrong marketing wastes people's months:

It would have been nice to know this MONTHS AGO, before I went down the all native code route with my Metro app.

share|improve this answer
1  
Your links both state you can use C++ for WP8 development, and it's only XAML which requires C#. Furthermore, Direct3D is only supported by C++. –  Lee Nov 24 '12 at 19:13
    
@Lee, can you develop non-Direct3D app without using C# for WP8? –  Comptrol Nov 24 '12 at 22:50
add comment

C++ still have Header files, flexible preprocessors (#define), ... such stuffs some people considered these features 'evil' or 'difficult to manage'.

C#, on the other hand, use metadata, no need to write and maintain header files.

About Microsoft adding more features to C++: Not a wondering matter.

Every C++ compiler is adding more features, including C++11 features. gcc is also.

share|improve this answer
5  
If all you can say bad about C++ is header files well, you've indirectly proven the point. I can list a whole host of serious C# issues, non-portability, non-deterministic, run-time overhead, proprietary, etc. –  user805547 Dec 29 '12 at 19:47
    
Use the right tool for the right job. C++ is great at companies like Intel for various unmanaged code performance needed low level to the medal projects, but if you need a website / web service which every company DOES, than good luck with C++ for that! –  Tom Stickel Oct 10 '13 at 7:04
add comment

No, Windows 8 is all about using whatever language you need to (or know) get the job done. JavaScript, .Net languages (C#) and C/C++ are all supported equally.

Nothing is being replaced and it's up to developers in the end anyway. There is however a push for better battery life which WinRT makes easier.

The exception is games where C++ is getting more support, especially on Windows Phone 8 while the managed languages have no native support (aka no xna).

share|improve this answer
1  
+1 Microsoft are desperate to get Windows 8 adopted in the smartphone and tablet market. Apple make more revenue from iPhone alone than Microsoft do in total. One obstacle is that there are very few apps for Windows phone/tablet compared with the established platforms. So they want to make it possible for anyone to create an app, in their favourite language. C#, C++, or JavaScript. –  MarkJ Nov 1 '12 at 6:16
    
I don't know why they decided to drop native c/c++ support starting from windows phone 7. Since that day, windows+windows mobile became from 90% major platform for our company shifted to 10% importance. 10% is only because of best development tools (visual studio), otherwise we don't make anymore products even for windows desktop. –  Pavel Nov 1 '12 at 8:17
1  
@Pavel I'm not sure what you're saying there.. –  Daniel Little Nov 1 '12 at 9:13
    
@Pavel -they dropped native code from WinPhone7, then dropped managed code from WinPhone8. Maybe you can re-visit the platform now, or just ignore it until/if it gets a much bigger market share. –  gbjbaanb Nov 2 '12 at 13:23
add comment

DXM wrote:

So the focus (at least in Microsoft's eyes) is back on C++ because now we care about battery life. Higher level code = more instructions = more juice required.

According to this words choosing Java as primary language/framework for Google's Android was a mistake. It was not. Higher level language usually means getting things done faster and I think this is the most important thing to Microsoft and Google. The more and better applications are created for the platform, the higher is profit of the OS producer.

On the other hand there is plenty of software for Windows still written in C++ so pushing those developers to switch to C#/JavaScript/anything else would be insane. Microsoft focus on giving a possibility to develop Win8 apps to as many developers as it is possible that is why in my opinion they decided to support C++ and JavaScript in Win8 development stack.

share|improve this answer
5  
Java was a mistake. If you want raw performance (and you often do) then you want to write in C/C++. If you want developer productivity then you want a higher level language like Python or PHP or Ruby or JS. Java (and C#) are middle-ground systems that give you neither the best performance or the best productivity. As it is, C++ isn't so bad - you can get good productivity from it once you know what you're doing. –  gbjbaanb Nov 2 '12 at 13:20
7  
@gbjbaanb I have mixed feelings about your comment: a few years ago, putting Java and C# on the same level of abstraction would have made sense, but the introduction of LINQ, lambda expressions and async programming features in the newer versions of .NET have moved C# to a higher level (Java is going to catch up on the lack of functional programming in JDK8, but that's still in early access stage). –  codesparkle Nov 2 '12 at 15:21
    
I so wish I could find that freakin' video. Seems that people are arguing with me whereas all I did was repeat what one of the lead developers at Microsoft told the world. That wasn't my opinion. But just to play devil's advocate, are you convinced that my galaxy S would not have longer battery life had it used more C++ instead of Java? So far I haven't been impressed with that phone's battery life. :) –  DXM Nov 2 '12 at 18:11
2  
@gbjbaanb fortunately, WCF is only a tiny part of .NET, and generalizing that to apply to the C# language is invalid. Have you actually used the new features since .NET 3? Because VS isn't such a great development environment at all (in fact, it's truly annoying without ReSharper). So, considering that this very site (and the whole SE network) is built with C#, your comment seems a little inaccurate. –  codesparkle Nov 3 '12 at 0:40
5  
@gbjbaanb: I would say that it was assertion without evidence that middle-ground systems that give you neither the best performance or the best productivity are a mistake. Given that performance and productivity are both important, the best solution is one that balances the two, and a middle-ground choice like Java or C# is an excellent choice for many use cases. –  Carson63000 Jan 8 '13 at 0:42
show 6 more comments

I know about C++11 features but I would like to hear your experiences

The thought that people would prefer C++ over C# (or pretty much any other post 1990 [non-php] alterative) for general purpose programming is laughable. C++11 adds some good missing bits, but it's still nailing legs to a dog.

C++ has some good niches, and it's still the best option on some platforms with limited compiler support. But no, modern C++ is nowhere close to replacing anything except perhaps antiquated, broken C++.

share|improve this answer
27  
Read what you are writing. You are outright claiming that using C++ for general purpose programming over C# is laughable. Is this sincerely a fact you believe in, or is it merely your own exaggerated opinion? –  zxcdw Oct 31 '12 at 14:26
31  
@zxcdw - If I have 100 general programming problems, I will get ~90 of them done faster, better, with fewer bugs using C# or Java or Python or Scala or... And that's being generous. This is the common viewpoint of pretty much every professional programmer I know; even the ones who use C++ as their primary language. –  Telastyn Oct 31 '12 at 14:40
26  
@zxcdw: I'm a hardcore C++ developer. I've done C++ for 15+ years and worked mostly on back-end apps that need C++. I've been all over STL and half the Boost. Much to dismay of my team I've introduced template metaprogramming in few places that I thought deserved it. Point I'm trying to make is that I love C++ and working with it. Having said that, I agree with Telastyn, if I have a general problem that doesn't require what C++ has to offer, I would rather pick up C# or even Python. They are higher level languages and you simply get things done faster in them. This true at least for Win devs –  DXM Oct 31 '12 at 15:22
14  
If all you have is a hammer, everything looks like a nail. The improvements in C++11 won't diminish the pervasive impact of C# and other similar, but perhaps more platform agnostic languages, rather it will keep that ship afloat. The biggest selling point of C++11 remains that it can be the end-to-end language for a system that pokes around in the depths of a system, yet offers the opportunity for tinkering around with higher order abstractions. –  JustinC Oct 31 '12 at 18:45
5  
@DXM: I have a similar experience: > 15 years of C++ (C++ is the language I have most experience with) and the only reason I see for using it is execution speed (but I could easily switch Pascal or Ada for that) and some nice libraries it offers (such as Qt). Otherwise I find other languages like Ruby, Scala, or Haskell far more interesting to work with. I think C++ replacing C# would be a step backwards. –  Giorgio Oct 31 '12 at 20:26
show 13 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.