18
\$\begingroup\$

Note: This is not a 'give your opinion' question about C++03 and C++11.

Our game engine, written in C++03, is designed to be compiled on Windows, OSX and iOS. Linux support is planned for the (very) near future. Our experience is limited when it comes to consoles, which is why I am asking this question.

Currently, we are debating whether switching to C++11 and using non-compatible features of the C++11 standard could pose a problem in the near future when we need to port our engine to any of the current gen consoles (perhaps the compilers supported by some console(s) do not support C++11 yet? We don't know...).

So, game developers who have experience across multiple platforms and consoles, do you think we should stick to C++03 until the new generation of consoles arrive and most everybody has switched to C++11 standard (have they already?). Or are most consoles using/support compilers (VC++, GCC or variants?) that are already supporting C++11 features?

\$\endgroup\$
6
  • 1
    \$\begingroup\$ My knowledge is somewhat out of date so I won't post this as an answer, but my past experience of console compilers is that you're lucky if they match the old standard, never mind a new one. \$\endgroup\$
    – Kylotan
    Commented Nov 27, 2012 at 21:59
  • 1
    \$\begingroup\$ Which features and why are they so important that you consider using a standard that is not fully implemented even on the most popular development platforms? \$\endgroup\$
    – snake5
    Commented Nov 27, 2012 at 22:00
  • 4
    \$\begingroup\$ @snake5: auto, lambda's, template alias, c-tor delegation. These features will not only make our code more readable/maintable but imo increase productivity. Just the auto keyword is one of the things I miss a lot when I switch from C++11 to C++03. Other features such as variadic templates, although very powerful and can definitely improve code, we can do without (and are not implemented so far by VC++ compiler). \$\endgroup\$
    – Samaursa
    Commented Nov 27, 2012 at 23:47
  • \$\begingroup\$ Adding to what Kylotan commented, i fully agree with his opinion, and even add a particular example in my experience. If you re going to extend that engine to the android platform, which can be done using C++, you will have a bad time as the C++ features are incomplete in the NDK. You won't be able to use the new standard and even some things in the previous will be faulty. \$\endgroup\$
    – Grimshaw
    Commented Nov 28, 2012 at 0:00
  • 1
    \$\begingroup\$ @DevilWithin, I've been using quite a few C++11 features in the Android NDK without any problems. \$\endgroup\$
    – notlesh
    Commented Nov 28, 2012 at 1:04

2 Answers 2

19
\$\begingroup\$

If you rely on your code in order to pay for food and shelter, and you need to support cross-platform on unknown future platforms (or reasonably might need to support cross-platform in the future), then designing your code to rely on a bunch of unknown compiler writers' correct adherence to bleeding edge language standards is dangerous (and I would argue, irresponsible). It's dangerous for you, and therefore also dangerous for your dependents.

If you're willing to take that sort of risk for the sake of auto, then by all means, go for it. But I'm not going to advise you to do it.

Because in my experience, going cross-platform, particularly on consoles, is best accomplished by aiming for the lowest common denominator which you can be certain will work virtually everywhere, not by relying on all the latest whiz-bang language features. If someday you need to port to a platform which doesn't support them, you wind up having to rewrite your systems from scratch. Can you afford to pay wages/rent while that happens?

\$\endgroup\$
7
  • 4
    \$\begingroup\$ +1 for this (and the rest of the post, but this): "rely[ing] on a bunch of unknown compiler writers' correct adherence to bleeding edge language standards is dangerous". Experimenting with the latest toys is always fun, relying on them not so much. \$\endgroup\$ Commented Nov 28, 2012 at 4:32
  • 2
    \$\begingroup\$ I'm always really anxious about giving these "be cautious" answers, particularly when they clearly aren't what the original poster wants to hear. But I've seen big compiler bugs on consoles too many times in my career for me to feel comfortable jumping onto new language standards in a cross-platform project. Needing to rewrite your code to get around issues in a compiler is never any fun, particularly when you're under a deadline. \$\endgroup\$ Commented Nov 28, 2012 at 5:21
  • \$\begingroup\$ I'm not going to downvote this but the new C++ standard is so much more than syntactic sugar such as the auto keyword. \$\endgroup\$
    – vdaras
    Commented Jul 2, 2013 at 13:38
  • 1
    \$\begingroup\$ @TrevorPowell, you said that the risk that he would take was for the sake of auto keyword, when there are much more important and fundamental features in the new C++ standard. Some of them, like rvalue references, would be have to be taken into important consideration when thinking about the risk. \$\endgroup\$
    – vdaras
    Commented Jul 4, 2013 at 14:17
  • 2
    \$\begingroup\$ @TrevorPowell that's why I said that the post isn't worth downvoting despite any arguments I have about it. I believe that this is a good post, I just wanted to clarify that the new C++ standard has some very important features and considering using it wouldn't just be about a minor thing like auto. \$\endgroup\$
    – vdaras
    Commented Jul 5, 2013 at 9:39
6
\$\begingroup\$

If your willing to do a bit more work, you could look into refractoring solutions. clang has some interesting stuff happening in that area currently. It should be possible to use the auto keyword, run it through the refactorer which will find all uses of it, resolve them for you and output the code then compile it with whatever you want.

But that means less time to work on your game.

There is also the potential for some extra features, for example reflection. You could create a class and automatically generate a list of all the properties to inspect at runtime. Could be very useful for scripting, producing game editors and so on. EDIT: Check out clreflect.

http://cppnow.org/session/refactoring-c-with-clang/

http://www.youtube.com/watch?v=mVbDzTM21BQ

http://clang.llvm.org/docs/Tooling.html

http://clang.llvm.org/docs/RAVFrontendAction.html

\$\endgroup\$
4
  • \$\begingroup\$ Highly interesting; have you tried it yourself for this (or a similar) purpose? \$\endgroup\$ Commented Nov 28, 2012 at 9:11
  • \$\begingroup\$ Not yet, decided to wait until it was a bit better developed but last time I really looked into it, it was only in the svn. \$\endgroup\$ Commented Nov 28, 2012 at 11:26
  • \$\begingroup\$ Very interesting (+1) \$\endgroup\$
    – Samaursa
    Commented Feb 13, 2013 at 16:13
  • \$\begingroup\$ This reminds me of something like python's 2to3 but in reverse and a lot more awesome but probably more difficult to use. Man, how much better can auto get? \$\endgroup\$
    – Steven Lu
    Commented Jun 30, 2013 at 6:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .