Link to home
Start Free TrialLog in
Avatar of phoffric
phoffric

asked on

Make a case for getting multiple teams to upgrade to modern C++

Background: i work in a red hat and Windows 10 environment. We have models written in Matlab and Simulink that the developers will convert to C++ in order to get higher speed simulations. We do not like the C++ code that can be generated from these two products. We have a simulation proprietary framework which provides us with many math APIs for C++.

We currently use C++03 with Visual Studio 2010 and g++. Lead developer has no experience with C++11 but he would like to convince a large community of divisions to upgrade to C++11 . I asked him what skill levels of developers would he be bringing in . He said his group cannot afford the best, and he believes that C++ 11 is more complicated than C++ 03. Recently I've been doing this survey of multithreading capabilities in C++11, boost, Pthreads, WIN APIs , and while I can see that C++11 features are rich , they are also complicated to use correctly . For example if you want to squeeze performance out of a program that uses many cores , then you have to learn about the C++11 memory model, and be aware of all the tricky race conditions that can occur when the high-level code is done out of order as result of compiler optimization .

 Could someone give me a list of C++11 features that an average C++ developer could use and explain how it is beneficial with a strong argument that we convince a large community of divisions to agree to upgrade to C++11 .

 Two items that come to mind are multithreading and dimensional analysis capabilities ( for example, units). They are now built into the language. I think the argument there is that we can have portable code to handle multiple cores with lots of documentation to show the ease as well as the pitfalls when using these features.

A few months ago the lead mentioned auto, but even there I think there are pro's and con's if overused.

My C++11 experience is limited in that I've been learning pieces of it and have only written some toy programs.

Lambdas are convenient but may go against another goal which is to create a reusable library functions. Plus , from what I've seen, members tend not to be as well-documented as separate functions or functors.

Meta programming is powerful but it may require more skill than the group can afford.

 Showing how individual features can support the iron triangle of parallelism (I.e., performance , productivity , and portability ) is one example of an argument that may bear some weight .
https://m.youtube.com/watch?v=DS2m7T6NKZQ (5 minutes into this video in case you are interested)

 I am guessing that for each new feature there is possibly another iron triangle associated with it . Also arguments about maintainability maybe useful. There lies the rub since for the program to be maintainable by average developers we will not be able to do advanced techniques like meta-programming.

One constant argument is portability since we work in both windows 10 as well as Red Hat . But I'm sure the managers will say but that's why we use C++ 03. It is portable. Of course, managers would love to hear about productivity gains in the short-term; and the enlightened managers would be concerned about productivity gains in the full lifecycle of a large long-term project .

Ease of profiling and debugging multiple threads might also make a good argument.

Thank you.
Paul
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phoffric
phoffric

ASKER

For the most part I will be developing new code and not have to convert old code to C++ 11. I think that is what Sara has to do.
I will be thinking about this question more next week. I will check to see whether I need to persuade non-technical managers or to persuade technical developers. Or both. My guess is that I'm going to need powerful arguments that appeal to non-technical directors, since in the past I have seen them resisting change based on developers idea that something would be really cool to work with.

 I have limited experience with Visual Studio 2015 community. I was able to work in threads by using breakpoints . In my previous job I was using C++ 03 and a TotalView IDE which allowed for multiple ways to debug and view running threads. Does Visual Studio 2015 have better thread debugging view than 2010? In TotalView I could pause the program and get a visual call graph of multiple threads, and could even move the blocks around to organize the call trees for better understanding.

 Earlier this year I did go through a quick survey of new features in C++ 11. Since you mentioned lambda , I looked up benefits of lambda versus functions. "syntactic sugar" is the common expression.
https://stackoverflow.com/questions/4686507/lambda-expression-vs-functor-in-c
https://stackoverflow.com/questions/27256062/when-to-use-functors-over-lambdas

 Move Semantics seems very beneficial due to performance increases. I recall Herb Sutter saying last year that if you take your existing program with standard library containers and build it in C++ 11, then with no change to the program, it will run faster thanks to move semantics which eliminate many temporary constructions.
>> Well, you already have a lot,
 What I wrote in the OP are just rough glimpses and guesses as to what may be useful. So if you have strong arguments that explain benefits better , then I would appreciate that very much. Right now , I honestly don't think that if I were a manager , and if I was told C++ 11 is very complex compared to C++ 03 , without some benefit that I could take to the stakeholders who probably don't care how the job gets done just as long as it doesn't cost too much and gets done faster, I doubt that I could support the upgrade to C++ 11. I am not a manager and would like to switch to C++ 11, because I have faith that this huge effort was done to improve some aspects of various iron triangles. But I have to turn that face into more substantiated evidence.

Since Sara has already looked into C++ 11 , maybe we should come up with strong arguments to convince her to switch . If we can do that , then maybe I'll be able to convince developers who then, in turn, may be able to persuade non-technical managers.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Read this link regarding dependent types.
http://en.cppreference.com/w/cpp/language/dependent_name
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
C++14 allows auto return type in all cases. I'm not sure I understand why that's almost correct.
Thanks for the inputs. I have decided to put on at least one hat as a defender of C++11 when I present my pros. I think the lead wants to get C++11. But I will also keep a local list of cons in case he wants to prepare a defense against other divisions. As long as there are pros, then one argument might be to say: don't use the harder features (which by the way, make C++11 great). I will post a list of features/examples/benefits as soon as I complete my end-of-month deadline on surveying 2D interpolation techniques.

This seems to be a serious critique of C++11 threading:
Plain Threads are the GOTO of todays computing - Hartmut Kaiser - Keynote
https://www.youtube.com/watch?v=4OCUEgSNIAY

I've already been nixed as for using C++17 if that solves the critique (although there are references to 2020).

I did notice this comment:
>> this doesn't compile with vc 10 compiler.
If that means Visual Studio 2010 compiler, then for this discussion, we should not be using that. I am using for this Make a Case question Visual Studio 2015 Community.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, I see what you mean. Yes, functions returning type "auto" have to follow the same rules as functions with templates, the compiler needs to see the function definition before it can be called. Sorry, I was just elaborating on your earlier answer. Heh.
No problem :o) I wish I could have explained it better from the beginning ...
>> don't use the harder features
I'm just wondering how you determine what is considered "harder"? I mean, what you find easy I may find hard and, at the end of the day, any C++ programmer should be able to read up about a language feature and use it. If they can't I'd be concerned and ask the questions, "why are we employing them as C++ engineers".

>> I am using for this Make a Case question Visual Studio 2015 Community.
Oh man, you guys really are working on old tech :)
>> wondering how you determine what is considered "harder"?
 For example, I consider C++ 03 meta-programming to be hard, and I am guessing that C++ 11 enhancements to that will make it harder . Lead has expressed concern that if I write something that he has trouble understanding but eventually does, then how will the future hired C++ developers be able to handle it since they cannot afford the best.

>> If they can't I'd be concerned and ask the questions, "why are we employing them as C++ engineers".
 Good question . In fact at Tuesday's meeting I asked this exact same question . I asked how real-time are we going to go because the more real-time and deterministic our program has to be, more expertise is required to handle this case. I saw the managers scribbling down fervently some notes when I brought this up . There is definitely some issues in trying to match up their long-term requirements and their ability to fund them.

>> Visual Studio 2015 Community.
I am using 2015 at home to explore C++ 11 capabilities for this video. At work we have the luxury of using Visual Studio 2010 .
 What higher technology program are you using?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think the managers I work for now agree with you for the most part. Unfortunately, they are constrained within a huge bureaucracy of  very tight budgets. The higher-up managers have to make tough choices of us little birdies squawking for a little wormy morsel. :)
Here's a short story about using newer C++ compilers: In our company it has alway been very hard discussed when to switch to a newer version, because the lead is quite conservative, fear- and careful).

For many years I thought this is nonsense and tried to push them, but at least with Visual Studio 2015 I found their carefullness was reasonable: Since we had a time without many urgent work to do we decided to start with VS 2015 soon after it was released. After some weeks of fixing bugs, removing warnings and testing we found one new error, a strange mis-behavior in STL - after lot of analyzing we found it was caused by an error in a C++ runtime DLL (which was part of the appropriate redistributables pack).

We reported this error to MS, they confirmed it was really a bug and promised to fix it in Update 1. In between we had to use a workaround, no problem, we did it and waited. As soon as Update 1 RC was released we tested the issue and found it was fixed. But: we found there was another new error, IMO a real critical one (the result of some integer substractions in a row caused a sign error with any kind of optimization, i.e. /O1, /O2) - unfortunateley, allthough we reported this error to MS asap they weren't able to fix this confirmed problem in final Update 1.

This was really scary, because allthough we found more than one simple workaround in the place where we found the error, but we had no idea, how mony occurances of similar code we probably have in our code (it was just a row of four statemtens like 'x = a - b;') - we weren't willing to risk releasing our software in this case, so we had to turn back to the previously used VS 2010 and were blocked with VS 2015 until Update 2 solved this bug too.

After this experience we again decided to wait longer before we start using a newer version. It's not nice, because I really would enjoy using new features like i.e. C++17/20 - but after this I understand very good why deciders tend to stay one step behind.
Similar, we recently upgraded from Visual Studio 2017 15.2 to 15.3 and discovered Microsoft had introduces a serious bug that caused initialisation of COM objects to crash under certain circumstances. Fortunately, we always verify everything before we upgrade and we were able to catch this serious problem before it caused us significant issues. Fortunately, the issue was fixed in 15.4 and we're now using that version; however, this does show that - although I am a proponent of always using the latest version of a compiler - one has to do due diligence before adopting.
Yes, I completeley agree, but in reality it's difficult for us, we're a really small company (five developers) working on a program started 1999 with VC++4.2, today it's about 80 DLLs, some EXE, overall about 3 Mio. lines of code, and it's impossible to re-test everything with a suitable effort. Therefore we decided we always stay one step behind. As told, not nice, but probably the safest.
Happy New Year!
I hope to get back to this in January after I complete my current project.
Sorry about the delay on this question but priorities changed over the last couple months. But the lead developer is going on a training for two weeks starting Monday. So next week I will start summarizing a report on why we should get C++11.

HR reason #: if we are planning on growing and hiring Junior Developers they may want to be in the 21st century.
My hope is to conclude this discussion by the end of this week. Thanks for your patience. I am copying your good responses into a word document. So far, I am very impressed with what I have seen. I got as far as https:#a42342934 and have one question on this post.

@Zoppo, you wrote:
>> And, just to mention, allthough as told it's C++ 14: auto can be used to write generic lambdas,

Is everything beyond that statement C++14? I probably should just include C++11 benefits, so if it is all C++14 beyond that statement, I'll leave that out of my document. If some is C++11, are you able to edit that post so as to mention C++11 where applicable?

BTW - on the home front, we finally got Adobe Reader installed on only one of the workstations. (I never thought I'd be thrilled to say that!!!) I also got VS 2013 installed. It isn't installed correctly, but at least they are trying. I'll at least be able to try out your code snippets. I'm also hoping to run a long-running program in both 2010 and 2013 to see whether 2013 has better performance, since I learned that C++11 code using containers may run faster due to implicit move semantics. I'll let you know once the installation is working.
Hi,

the things following the part with the generic lambdas AFAIK are C++ 11, i.e. the new return type definition using a trailing '-> <return type>' is: http://en.cppreference.com/w/cpp/language/function

ZOPPO
You made some strong points from your personal experience that both developers and managers will appreciate to the benefits of starting new projects in C++11.

If there are any additional bullets from these two links that would enhance further the benefits of C++11 over C++03, I certainly would appreciate hearing from you if you have had good personal experience with them. I have looked things up on the web which often are full of contradictions, but I know I can trust your judgement. :)
http://www.stroustrup.com/C++11FAQ.html#11
https://blog.smartbear.com/development/the-biggest-changes-in-c11-and-why-you-should-care/

I am going to only present the positive aspects of moving to C++11. If another group in our team disputes a point, I may ask for some help in another question. I value your excellent personal experience with C++11.

>> And, just to mention, allthough as told it's C++14: auto can be used to write generic lambdas,
I'm not clear what part of this post is strictly C++14. Could you please clarify?

>> any C++ programmer should be able to read up about a language feature and use it.
Thanks for influencing me. I'll stick with this viewpoint.

>> >> I am using for this Make a Case question Visual Studio 2015 Community.
>> Oh man, you guys really are working on old tech :)
    Hey, at least I got VS 2013 installed. When they fix the kinks (like getting ItelliSense working), I'll be on a roll (provided that our case to move forward with C++11 holds water).

>> After some weeks of fixing bugs, removing warnings and testing we found one new error, a strange mis-behavior in STL - after lot of analyzing we found it was caused by an error in a C++ runtime DLL (which was part of the appropriate redistributables pack).
    Good example. I've experienced similar scenarios in other software packages, where we had to go back one version. Part of my argument for C++11 can be that this specification and implementations are now very mature in VS 2013 and g++ 6.x; so what you read is what you get - WYRIWYG (I hope).

>> it's debugging and understanding the massive error reports that's the tricky part.
    In another company I got one of those 4 page error messages from Boost Spirit because I left out a semi-colon. I wonder if I can bring Concepts into C++11 to reduce the number of error pages. I'll take a look at this article.
http://www.osl.iu.edu/publications/prints/2005/siek05:_concepts_cpp0x.pdf

Thanks again for your patience. I have gone through your posts and will take a stab at reviewing all the code. I'll take it on faith that it works, and it will not be a show-stopper if I don't understand some of it.
Thank you for this describing the benefits of C++11 over C++03. I also appreciate Sara playing the Devil's advocate whose arguments then elicited responses from the pro-C++11 camp. Sara's remarks show me why the lead expressed concern in learning the new semantics. But he got a pretty good handle on C++11 using Qt with no prior programming experience and he did it on his own with no mentors. So, maybe he will go towards modern C++.

He told me yesterday not to put tickets in for Visual Studio 2013 because he is trying to get VS 2015. One argument I planned on making is that C++11 and Visual Studio 2013 are mature products and we likely not have any difficulty with bugs. Is this true for Visual Studio 2015, or are there still bugs. One reason he wants to go with VS 2015 is that it doesn't require Microsoft Compact SQL (and this is what seems to be giving our IT group problems - I don't get IntelliSense, which is a minor issue.)

Our projects are new so I don't have to be concerned about porting. Other groups using C++03 should have no problems, I believe, since they should be able to build their projects in VS 2013 or 2015 using C++11 and be able to do that without making any changes, I believe.

Wish me luck in getting C++11 - I hope to get into this decade. :)
You're welcome, and sure: good luck! :o)