21

Possible Duplicate:
What does the latest “C++ Renaissance” mean?

Lately, I hear a lot about C++ Renaissance. What is that?

C++ is currently undergoing a renaissance. This means that, by definition, the language, compilers and compositional tooling are evolving and coalescing into a state that maximizes native developer efficiency, productivity, and creativity across hardware and software domains.

I agree that C++ needs a lot of improvements, mainly, because it was updated in Neolithic Age (98,03). What really bugs me is the Build conf. They've showed a few metro style apps written in C++ and XAML - like RSS reader or Piano.

I have a feeling that C++ is an overkill for this kind of apps and only case when I see the advantage is battery power, but is it true? C# as well as C++ calls WinRT which is native and C# has only tiny runtime overhead.

Can someone provide case study or hard data where use C++ in windows 8?

I think it will be status quo (games, servers, OSes, databases, apps like Photoshop will be C++ and other client apps run .Net) and renaissance is just a marketing slogan.

Lukasz Madon
  • 1,496
  • 13
  • 22

6 Answers6

31

I believe that every senior programmer / architect should watch Herb Sutter's presentation at C++ and Beyond 2011.

Basically, he claims that .NET and Java indeed offer better productivity. However productivity is not all. Battery power and performance are becoming more important for hand-held devices. For big-data server-farms, if you can squeeze your processing to 1000 cores instead of 2000 cores - you'll save more money on energy and maintenance than the money you'll lose on the extra programming hours.

So both for small and large systems - productivity is not everything, and even not the most important factor. When it comes down to processing power and battery power - C++ wins.

The new C++ standard offers extra productivity, without sacrificing performance. It shifts the balance even more.

Lior Kogan
  • 1,467
17

I agree that C++ needs a lot of improvements, mainly, because it was updated in Neolithic Age (99).

C++ was never updated in 99. The first C++ Standard was 98. And then another one in 2003. And a new one has just come out this year. That's not exactly neolithic. More importantly, it's worth noticing that programming techniques that C++ had since well before 98 have, relatively speaking, only just come into .NET languages, like generics and functional APIs. C++ has had templates for vastly longer than generics have existed in C# - and generics aren't even as powerful as templates. Arguably, it's C# that's playing catchup, decades later.

I have a feeling that C++ is an overkill for this kind of apps

Overkill how? Apart from the idea that some people might prefer C++ for subjective reasons (which I could give a dozen of if you're interested), plus the fact that it doesn't require a 100MB install to get running on a consumer's computer, for example, or works on many more platforms than C#.

And C#'s runtime overhead is not tiny. At all. In fact, the smaller the app, the greater the proportion of time is spent just loading up the CLR.

As far as I can tell, the fundamental problem is that Microsoft has two divisions - WinDiv and DevDiv, I believe.

WinDiv can't be bothered and feels compelled to lump C++ in with another language- first it was C with the Win32 API, and now it's C# with the Metro APIs, which are C++ APIs only in the sense that technically, they're compiled by a C++ compiler and actually have very little in common with a C++ design. In addition, WinDiv doesn't learn from their mistakes- for example, even in the new Metro APIs, you can't mix Metro controls and DirectX rendering. Seems to be the kind of thing you would have fixed after the airspace problems with the previous generation of native controls.

DevDiv on the other hand seems to actually know wtf they're doing, for example, see the Concurrency runtime in Visual Studio 2010 and C++ AMP in vNext, which are awesome. They also produce some pretty sweet tools- the IDE improvements for C++ in vNext are quite good, and AMP is a big deal, even if unfortunately, that means few new C++11 features.

The problem is that WinDiv produces a lot more content than DevDiv, for example, sockets and UI libraries. So there is a C++ renaissance- it just only applies to the stuff that the unfortunately tiny DevDiv library team managed to paste over the WinDiv stuff.

DeadMG
  • 36,914
6

C++ is starting to see some more importance on server side applications. Efficiently using the processor saves millions in server costs. If your app runs 7 times slower then you need to buy 7 times the servers, 7 times the cooling costs, 7 times the floor space, etc. Facebook started using some C++ for this reason. Google uses many languages, but their core is C++. If you expect massive load, your life can be made much easier if you use a native implementation from the start.

People seem to think garbage collection is what makes development easier. In my experience it's not, especially when your code is holding external resources. The C++ model of destructor clean up is cleaner and more modern than the Java model.

Consider this java psuedo code:

public void someMethod()
{      
        FileObj f = null;
        try
        {
          f = new File("/somePath/myFile.txt");
          String str = f.read();
          System.out.println(str);
        }
        catch(CustomException ce) { /*la */ throw ce; }
        catch(PathNotFoundException pe) { /*la */ throw pe; }
        catch(Exception e) { /*la */ throw e; }
        finally
        {
            try { if(f !=null) f.close(); } 
            catch(Exception e) { /*la */ throw e; }
        }
}

In C++ you could so something just as safe, without so much bloat. Just one line of code with all the saftey of the pseudo code above.

void someFunction()
{
   FileObj f("/somePath/myFile.txt");
   string str = f.read();
   cout << str;
   //the file is magically closed even if an exception occurs during f.read();
}

Edit: Changing pusedo-code methods from "main" to "someMethod".
Edit: Re-throwing exception in java pseudo code to make it equivalent to the C++.
Edit: Re-naming File to FileObj so psuedo code is not confused with real java libraries.

Lord Tydus
  • 1,441
4

Of course it is a marketing slogan, but it shows that Microsoft is (again) committed to support native code as a first class citizen on the new platform.

Whether it is of any interest to you personally, that is another question - if you prefer some other language and it does the job for you, feel free to ignore the "C++ Renaissance".

4

It's also C++ is portable. You can write a C++ app in windows move it to Mac/Linux/Android/iOS albeit with some fiddling. Although this probably isn't an angle MS is interested in.

When windows was the only game in town then C# was safe to use.

There are other alternatives Java/Python etc. They all come with a run time and so take some time to port to the new environment and as all these new platforms are coming then native is safer.

Also C++ (and C) are the only ones that have multiple compilers from multiple vendors - so you are safe that no one is going to change the rules - Oracle with java, MS with C# etc.

So if you're writing an app and you want to move it to different platforms then C++ is a very safe choice.

daven11
  • 769
3

Can someone provide case study or hard data where use C++ in windows 8?

Well, the OS is written in C++.

The quick answer is that nobody with half a brain wants to design a commercial app that runs 10x slower and drains more battery than competing apps.

C Flat
  • 31
  • 1