id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,phab_field 2669,Migration to C++11,Yves,,"For discussions and opinions, please refer to the forum thread [http://www.wildfiregames.com/forum/index.php?showtopic=18926 here]. == Overview C++ is the next version of the C++ standard after C++98 and C++03. There's already C++14, but that's currently out of scope because it's definitely too early for that. This standard introduces many new features and addresses shortcomings of the language. C++11 still supports all features of the earlier C++ standards (with very few exceptions) and if the compiler supports it, it can be enabled for existing code by passing an argument to the compiler (no code changes required). The C++11 standard consists of many new features that have to be supported by the compiler. Some of the features are more widely supported by older compilers and others would require newer compilers. In addition to saying yes or no to C++11, we also have to define which features we want to support and, as a consequence, which compiler versions we support. As a reference, check [https://developer.mozilla.org/en-US/docs/Using_CXX_in_Mozilla_code Mozilla's C++11 guideline (draft)]. For more information about C++11 refer to: * [http://www.stroustrup.com/C++11FAQ.html Bjarne Stroustrup's C++11 FAQ] * [http://www.youtube.com/watch?v=nLUBVb57piQ This video for a short introduction] * [http://www.youtube.com/watch?v=0iWb_qi2-uI This video for an in depth presentation of the evolution of C++ and the ""new"" C++11] == Decision There's not really a decision if we want to switch to C++11 or not, it's more a decision if we want to switch now or later. As far as I know, C++11 will become mandatory at some point and it won't be possible anymore to switch it on or off. If we decide to switch now, we have to agree which subset of features we want to use and which ones not. Such a decision should probably be based on how well the features are supported by compilers and which versions of compilers we need to support. === Links for supported features Some information on support for C++11 features in different compilers: * [http://wiki.apache.org/stdcxx/C++0xCompilerSupport Apache wiki: C++11 compiler support (different compilers)] * [https://gcc.gnu.org/projects/cxx0x.html C++11 support for GCC] * [http://msdn.microsoft.com/en-us/library/hh567368.aspx C++11 support for Visual Studio] == !Pro/Contra of C++11 === Pro * Improved performance (probably 1-3% when just enabling c++11 without additional changes. Depending on compiler and measuring conditions.). Additional improvements are possible by using the new language features correctly (like move constructors, improved template functionality, constexpr and others). * New standard was developed to improve shortcomings of C++ --> Provides better solutions in some cases (better error handling, improved maintainability, compile-time checks instead of runtime checks, style improvements etc.). * Allows us to use libraries that require C++11. === Contra * Requires programmers to understand the new C++ features * Requires additional care to avoid using features that are not supported as defined in our coding guidelines --> Could break compilation on other compilers * Although the new standard aims for improving the style of code, the mix of old code and new code and the additional possibilities could make it worse (hard to tell at this point) * Requires us to drop support for some versions of compilers === Required for * SpiderMonkey 31 requires C++11 support * WxWidgets 3 requires C++11 according to #2452, but it looks like that's not confirmed == What we have to do for the migration * Create a new Autobuilder with C++11 support. The current one uses Visual Studio 2008 and will have to be replaced at some point anyway. * Specifying ""C++11 supported features"" table * Trivial change in premake4.lua * The ABI should be compatible in most cases and it should not be required to rebuild all Windows Binaries as far as I understand. ",task,closed,Should Have,Alpha 18,Core engine,fixed,,,