Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When it comes to mobile game development on iOS and Android NDK, some developers write their own C++ containers, while others claim that STL is more than adequate for mobile game development (For example, the author of iPhone 3D Programming uses STL rather than Objective-C in his examples. His defense is that STL is no slower than Objective-C).

Then there are also mobile developers who abandon C++ entirely and develop games entirely (or mostly) in the C language (C89/C90).

What are the benefits and drawbacks of each approach?

share|improve this question
4  
The main criticisms against the STL are it's unpredictable memory allocation patterns and compiler support - both problems can be solved by using a STL alternative, for example EASTL or STLPort. –  Raphael R. Sep 28 '11 at 13:51
1  
Several answers from this question: gamedev.stackexchange.com/questions/268/… touch on mobile platforms and should give you your answer. –  Tetrad Sep 28 '11 at 14:35
5  
I suspect for many of the people "abandoning" (more like, not ever using) C++ on mobile platforms it's less about STL and more about the awkwardness of Objective-C++ (and C++ support lagging generally on Apple's toolchain). –  user744 Sep 28 '11 at 16:42
    
The real question is, can you write better? You're better off understanding the STL; and in the cases where it doesn't do what you want, implementing the behaviour you so require. –  Daniel Jun 15 '12 at 9:15
add comment

1 Answer

Let me tell you one thing first. C++ is faster than Objective-C calls. Objective-C uses message passing systems so it will have some runtime overhead when compared to C++. Just have a look at some of the comparisons here.

Coming to iOS general "app" development, it makes sense to use Objective-C built-in functions as performance cannot be a much criteria to some extent. But in game development, we need to consider these results.

When I was working on my previous project (Robokill), we optimized most of the code where ever necessary with plain-C calls (we converted our Objective-C particles class to a C++ class). Or you can even use Objective-C runtime functions for direct C calls.

Coming to your question, here's my answer: yes, STL is well optimized for its purpose. Even though the implementation code is not much readable, it's interesting to check the implementation once.

However, we can optimize Objecive-C code to some extent, by pre-caching the function pointers and making calls with the Objective-C runtime.

Hope this helps!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.