Search code examples
c++cc99c11c89

Using new standards


I've been told before (rightly or wrongly) that I should be using various older standards of C and C++. For example in a Uni module I did on C this year we had to use ANSI C (which I believe is C89?). Other times I've been told to use C99. Every time I'm told either of these, the reason given is that C11 is not safe to use, due to new features that may not be supported by every compiler etc. (I'm not a massive expert on this so explanation would be great).

It seems ludicrous to me that a standard is still not widely used 3 years after its release. Are these people wrong or is it genuinely a bad Idea to use C11 and C++11?


Solution

  • Neither, both... the bane of legacy.

    No you should use the newest tools available on your platform and that are compatible with the other elements in the system. New tools allow for "better" programming, safer programs, more concise programs, etc.

    Yes you should use older tools, well, very simply, a lot of work is maintenance. Some of it will be on very old systems... being familiar with the issues of the tools will help when changes need to be made.

    Your target audience (people and systems) will dictate what tools to use and what tools to support. The lowest common denominator almost always wins.

    For the same reasons, I think this is the principle motivation for backwards compatibility. If the new tools don't break the old code, then the progression forward is eased.

    In general, it is a good idea to use the newer language features with new compilers. There is a general move within the industry to support newer languages (even before the standard is final, e.g. clang and gcc with the upcoming C++14).