Thread: strange std::map behavior

  1. #61
    Banned
    Join Date
    Nov 2007
    Posts
    678
    you ignored my question, why C++ people care so much for efficiency?
    i bet you don't have templates on embedded systems compilers.
    then what's the point? different platforms can have differently optimized c++.

  2. #62
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by manav View Post
    you ignored my question, why C++ people care so much for efficiency?
    i bet you don't have templates on embedded systems compilers.
    then what's the point? different platforms can have differently optimized c++.
    The compiler for embedded systems should be fully C++ compliant - certainly the one we use is. We choose to not use templates (much) due to the fact that they often produce quite inefficient and often lead duplicated code in many places (because every time you include the template in one project, it gets a complete set of all the template code compiled into that source file).

    But even for PC's there is code that needs to be efficient - your code may not belong in that category, but certainly game developers will "care" if the frame-rate is high or not, and inefficient code will not give good frame-rate.

    Likewise, if you are working on a large database-project or some such (e.g you implement the functions in MySQL or some such), any extra time spent there should be avoided.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #63
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by matsp View Post
    The compiler for embedded systems should be fully C++ compliant - certainly the one we use is. We choose to not use templates (much) due to the fact that they often produce quite inefficient and often lead duplicated code in many places (because every time you include the template in one project, it gets a complete set of all the template code compiled into that source file).
    but you certainly avoid such stuff, mainly, because of scarce resources and, mostly because of little need of over complicating the stuff

    But even for PC's there is code that needs to be efficient - your code may not belong in that category, but certainly game developers will "care" if the frame-rate is high or not, and inefficient code will not give good frame-rate.
    they go far beyond what can be expected, they use inline assembly, then gfx cards help, then a library using all the hardware features etc. etc. some even avoid C++.

    Likewise, if you are working on a large database-project or some such (e.g you implement the functions in MySQL or some such), any extra time spent there should be avoided.
    if i am doing such a big stuff then std stuff is negligible compared to my large implementation, i will re write the stuff i need, the way i want it!

  4. #64
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Template-avoidance is a combination of "trying to get everything to fit in memory" and "don't help much anyways", yes. We have a "budget" of 32MB to fit "everything" into memory - that's OS, drivers, apps, data and anything else needed in our system. If it doesn't fit in 32MB, then it's time to "go on a diet".

    I very much doubt you can find any game that "avoid C++" - they may well not use for example STL, but the code for current games is almost certainly written using C++ - it makes the code so much neater when doing vector operations for example, and using macros/functions for vector operations would just make the code unreadable and slower. But the game programmers certainly care about what happens "under the hood".

    Rewriting "anything I need" is not a good philosophy, although sometimes it's necessary to write your own functions to do things - but it should not be done "because it's such a large system", but because there is a CLEAR AND REAL need to write your own functions.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. C++ list Strange Behavior
    By yongzai in forum C++ Programming
    Replies: 19
    Last Post: 12-29-2006, 02:56 AM
  3. Strange behavior of Strings
    By shyam168 in forum C Programming
    Replies: 9
    Last Post: 03-27-2006, 07:41 AM
  4. strange behavior
    By agarwaga in forum C Programming
    Replies: 1
    Last Post: 10-17-2005, 12:03 PM
  5. Strange behavior with CDateTimeCtrl
    By DonFiasco in forum Windows Programming
    Replies: 2
    Last Post: 12-19-2004, 02:54 PM