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?
12
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.
-
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.
-
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:
-
.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.
-
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.
19
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).
4
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++.
19
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.
13
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.
2
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.
1
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.
2
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.
2