C++ Renaissance: First Symptoms of Contagion in Traditionally Non-Native Teams

C++ Renaissance: First Symptoms of Contagion in Traditionally Non-Native Teams

  • Comments 23

You may already know Pete Brown but if you don’t, I’ll briefly introduce him here: he’s, like me, a Community Program Manager with Microsoft but while I’m focused on C/C++ languages and the Visual C++ tool, he’s devoted to client-side development technologies (mainly WPF and Silverlight, with some Windows Phone 7 and XNA, a bit less of HTML and JavaScript –Rey Bango covers these two web techs- and a bit of C++ as well, although this last hasn’t happened for months, if not years (even before last December, when there was no C++ Community PM at all). In his own words:

My C++ is slightly more rusty than an old tractor left in the back field for most of the century.

He recently had a problem to solve, he needed a fast, smart way to collect online resources for his own weekly report: the Windows Client Developer Roundup which, among others, inspired our Visual C++ Weekly. The tedious part in his case was to copy/paste titles with some special format, while eliminating some tracking stuff in the companion URL. That for each of the 25 links he includes per week.

He decided to create a browser add-in to deal with this all at once. Hopefully his solution will also serve to you if you need something similar, if you were planning to create an add-in or at least if you’d never considered that chance and his approach inspires you for any other problem you were having in browsing web pages.

But I’m not to reproduce his whole post here, just wanted to highlight the two main reasons why he chose ATL (and C++) and not any of the techs he’s more used to.

One of his reasons is very rational:

You can create add-ins using .NET and Script, but both have significant limitations as well as performance concerns. If you want to write an add-in of any complexity, you'll almost certainly want to write it in C++.

This demonstrates that Pete thinks as an architect when solving problems: he’s just not tied to the technologies he masters but he privileges the most adequate solution for a given problem. This principle applies, of course, for us as well: we should prefer alternative technologies to C++ when more adequate to solve a specific problem.

The other reason adds some emotional component:

I specifically wanted to do this in C++. No, not because I hate myself, but because I'm starting to see a resurgence of interest in C++.

Well, I said emotional although mixed emotions in any case: how is that about hating oneself if someone chooses C++, Pete? Hot smile In the same sentence, however, he opens the door to some hope when talking about a resurgence of interest in C++. He wanted to give C++ an opportunity to delight him back like before the rise of managed languages.

I haven’t talked to Pete for months. We used to report to the same manager a while ago when I was editorial director of MSDN Magazine but since I moved to Microsoft building 41 (where the Windows C++ team “lives”) I lost all contact with him. Looks like if he sees some C++ resurgence out there, it wasn’t me! Smile

Love is in the air so, dear readers, blog followers and C++ lovers in general: let’s keep beating our drum. Even louder. This is not about supplanting managed languages with C++, but just putting C++ back in the place it deserves as preferred technology to fully get the power and performance a platform features.

His solution may not have been the best as himself prevents:

Keep in mind, I'm relearning C++. If I did something dumb, don't hesitate to (nicely) point it out in the comments, especially if it's something other people shouldn't repeat in their own code.

He finally states

Works On My Machine.

Period. Angel

He just got three (3) comments by the time I’m writing this, what makes sense to me as I don’t believe that a huge crowd of C++ developers follow his blog. Why don’t we help him tune up his C++ background by signaling areas of improvement? That may pay back if Pete feels encouragement to keep addressing us as one of his audiences in the near future.

His approach is posted here: http://10rem.net/blog/2011/02/22/creating-an-internet-explorer-add-in-toolbar-button-using-cplusplus-and-atl.

Is this signaling that we’ll start seeing more C++ flirting from other community PMs?

  • "This principle applies, of course, for us as well: we should prefer alternative technologies to C++ when more adequate to solve a specific problem."

    Does the lack of support for native code applications on some of your platforms (Windows Phone, Xbox 360) mean .NET is a better way to solve all problems on these platforms?

  • @Shen: The 360 most certainly supports native code, but you have to be a certified developer (i.e. have $$$) to use it - the hobbyist stuff is XNA only. And I would be very surprised if WP didn't support native code eventually, although probably with similar restrictions.

  • Hi @Shen, nope: definitively the lack of native support doesn't mean that .NET is a better alternative because un any case we are not given options but a sealed door for one technology and one only way out thru managed. We are not choosing, then, so the axiom of the best tech to solve a given problem is not being applied there (what doesn't mean that .net wouldn't have sufficed for any case).

    I'm your advocate there. A few days ago I compiled all these claims for native support in WP7 and send that for the wp7 team. Not sure if, as your advocate, I'm to win the case but I keep my bets high. I'm confident that the same will start happening with other techs as well (xna, etc)

  • @Diego: Let's hope you will win the case then but I can't help being skeptical. To me the fact that such radical decisions were made during design time (basically that the technologies you guys are investing in cannot be used by the average developer on your new platforms) is a clear sign about the direction Microsoft wants to head in... When is the verdict expected? :)

  • Please keep up the fight @Diegum - we would LOVE to put our native C++ app on WP7!

  • I would like to see something like MSVC 10 (with the same partial c++0x support as on desktops) for the upcoming Windows CE 7. With full support of STL (I had spend many days porting STLport to Windows CE 6).

    Also it would be great to support MSVS 2010 (not 2008!) in tools shipped with Windows CE 7.

    All I said about Windows CE 7 relates to WP7 too.

  • @Shen: "Does the lack of support for native code applications on some of your platforms (Windows Phone, Xbox 360) mean .NET is a better way to solve all problems on these platforms?"

    .Net and C++ are not mutually exclusive.

    Can you write C++/CLI and compile it for the phones? (I have no experience of WP7 development so maybe you can't for some reason but, still, let's not confuse .Net with C#, or native code with C++.)

    @The root post: "If you want to write an add-in of any complexity, you'll almost certainly want to write it in C++."

    Agreed, add-ins *for native programs* are best written in native code. I've done it both ways and shoehorning .Net into an unaware native process will often fill your life with horrible issues. (Especially if two add-ins decide to do that to the same process.)

    Depending on the project I'm involved in, I've gone through years of only native C++, then only C#, then only native C++ again. It's less about the merits of the languages/platforms/frameworks themselves and more about the APIs, programs and libraries that the code I'm writing has to talk to.

    (I've also been tempted to use C++/CLI at times, as it's a great bridge between the two worlds for some types of work. The case for it was never enough to overcome the difficulty finding people who can maintain it, since it requires knowledge of both C++ and .Net.)

    When I'm using native C++ there are things I miss about C# and .Net, and vice versa. But none of the pros and cons outweigh the benefits you get from having all (or almost all) of your code in the same domain. For the same reason, if I was writing an add-in for a C# app, I doubt I would use native C++.

  • Is it possible to create an IE add-on using registration-free COM (with manifest files instead of registry entries)?

  • Please I want C++ for the Windows Phone too! Just open it up and let us do our work, even if compatibility is broke in the future. If you want the best apps, let the best devs make them with the appropriate tools.

    Thanks.

    Best regards

    Mello

  • I don't think WP7 can truly compete with iOS until it supports native C++ development. There are tons and tons of existing C++ code and most people will not rewrite their libraries from scratch just because someone in WP7 team thinks it's a good idea. I know I won't.

  • Same here, we have some C++ libraries we use to build software for iOS and Android devices and rewriting them in managed code just because some marketing guys at MS decided .net is the only way to go is completely ridiculous. It would cost us a lot of money and would lead to a (technical) regression.

  • I suspect (and hope) that the lack of native access on WP7 was just due to time pressure. They had to get v1.0 out the door ASAP, and so doing it this way buys them some time to actually design a usable native API. (Since they probably don't want to give you access to the Win CE APIs directly)

    Long term, prohibiting native code entirely just seems like a crippling handicap for WP7.

  • I think the lack of a native API on WP7 is probably due to their planning to port it to an NT kernel eventually, and wanting to make it easier to avoid compatibility problems.

  • SkuzEmWa

    The tedious part in his case was to copy/paste titles with some special format, while eliminating some tracking stuff in the companion URL. That for each of the 25 links he includes per week.

    I think an Apple II running at about 1 MHz could tackle that in ye olde funky Gates' BASIC and still require attention before one got around to even thinking about getting up to make coffee.  Or, to think of it another way, well, go ahead.  Who designed the 6502 anyway?

  • PS. Started to do a mini-app-server in C++ (again).  No WPF designer.  Thought again and stopped.  We ain't doing maths here, and we got 8 freakin' cores laying around slumming at 3 billion clocks a second (that's 24 billion if you line them up in a row, you know).  That's 24x 10^9 / 1x10&6 = 24 x 10^3 faster (clocks alone) that the 6502.  Factor in 8-bit registers vs 64-bit, a FP mul in a clock or two instead of 1000s, and, well, you see where I'm heading.  Sometimes, in the blink of an eye is fast enough.

Page 1 of 2 (23 items) 12