0

I have a relatively well-maintained, rather large code base using -std=gnu++98. What are the advantages of upgrading the language standard from gnu++98 to gnu++11 ?

If there are advantages, is it enough to just change from -std=gnu++98 to -std=gnu++11 ? Are there other options that should go along with this change (thinking about how -pendantic -pedantic-errors accompanies -std=c89 or -ansi for C)

Cherry Vanc
  • 781
  • 1
  • 4
  • 19
  • 3
    c++11 introduces move semantics and rvalue references. It's a huge change. – François Andrieux Feb 22 '18 at 21:00
  • 4
    See [What breaking changes are introduced in C++11?](https://stackoverflow.com/questions/6399615/what-breaking-changes-are-introduced-in-c11). – François Andrieux Feb 22 '18 at 21:02
  • Do you intend to make major changes to the codebase? –  Feb 22 '18 at 21:03
  • 2
    The most obvious advantage is the ability to use new language features. Most of these new features help by improving code readability, enabling better compiler optimizations, helping catch errors earlier, etc.. Of course, someone needs to write the code that uses those new features, so a lot of those benefits won't be free out of the box. – 0x5453 Feb 22 '18 at 21:03
  • 3
    This is a very concrete question and it should be re-opened. – Nemanja Trifunovic Feb 22 '18 at 21:07
  • In 1 years time, if you require help or assistance, you will have to ask about code that follows a 20 year old standard. This may start to become an issue with the advice you will be given. – Richard Critten Feb 22 '18 at 21:09
  • 7
    @NemanjaTrifunovic - too broad, rephrasing the question: what changed in C++ from C++98 to C++11 to C++17 - you could write a book. – Richard Critten Feb 22 '18 at 21:10
  • 1
    The question does not ask "What changed from gnu++98 to gnu++11". I understand that that will be too broad to answer. The intention is to know – Cherry Vanc Feb 22 '18 at 23:38
  • The intention is to understand if there are enough advantages before such a task is attempted – Cherry Vanc Feb 22 '18 at 23:47
  • 4
    @CherryVanc: Which is both too broad (there are a huge number of advantages, but not all of them are relevant to every project) and opinion based (how important a given change is will be heavily opinion based). Personally, I found C++ to be an annoying slog to write pre-C++11, and *much* nicer post-C++11 thanks to improvements in type deduction, functional programming tools, etc., but it's much harder to say a given existing code base would be improved; r-value references and move semantics on the STL containers may give you a speed boost, but otherwise it's easier programming that's the lure. – ShadowRanger Feb 23 '18 at 01:30

2 Answers2

2

(I'll try to provide a broad-strokes general answer. YMMV depending on specifics you haven't provided.)

For an existing codebase? Not many. Code written for C++11 and above can make use of a lot of new syntax and semantics and improve performance (e.g. with constexpr functions, move semantics and so on); in your case, that could be the standard library, or other libraries you're using which support a newer C++ language standard. But if the performance-critical code is your own, I would not advise promoting the standard version.

Having said that - if you were to revamp your actual codebase with C++11 (or better yet, C++14 or C++17 which are out), you would be able to benefit, in terms of performance, readability, maintainability, reduction of code size etc. That's definitely advisable, since more and more code will require C++11 or higher to compile, over time.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
1

The short answer is - it depends.

And it depends on

  1. What is the lifetime of the project from product owner's PoV.
  2. Skillset in the team
  3. Maintainability
  4. Project modularity
  5. Unit test & automation test coverage
  6. Risk (last but most important)

In terms of risk, it is important to quantify the cost of each risk item. For example: 6.a. cost of regression (if you take the plunge) 6.b. cost of attrition (if you dont take the plunge) 6.c. cost of taking the plunge (development effort)

It can be argued on either to upgrade or not to and you can get a convincing rational for each side.

My view: If the project is well designed (modular for one), unit tested and well maintained, I would do it piece meal and revisit my decision after piloting a small but critical module of the project.

If the project is not well designed or unit tested, I would use the uprade route as an oppurtunity to pay technical debt.

Ram
  • 3,045
  • 3
  • 27
  • 42