3 ms·
Something I genuinely don't understand "buttery smooth 3D game"s are created with C++ too but why isn't C++ an issue for games? Seems to contradict the premise
by xiaodai 5y ago
Something I genuinely don't understand "buttery smooth 3D game"s are created with C++ too but why isn't C++ an issue for games?
Seems to contradict the premise which is that programming languages were designed in the past and hence not efficient for modern computers.
- mort96 5y agoIf you use C++ in the "default" object-oriented way, your program won't be as efficient as it could've been. Computers are fast, so you can still make games which run well, but not as well as they could've been. C++ can also be used in ways which are really fast on modern machines. You can, for example, write code in a data-oriented "struct of arrays" approach with C++. The argument is just that C++ isn't designed with that in mind, and that a high performance language designed today could be designed with modern machines in mind.
- kaba0 5y ago> If you use C++ in the "default" object-oriented way, your program won't be as efficient as it could've been That’s way too general to hold any truth. C++’s classes are zero cost, SoA vs AoS is not always relevant. If I have three instances of my class, each doing something compute-intensive in a simple method, how is it different to dod? Also, even virtual functions are not necessarily any more expensive than the alternative if one knows what he/she does.
- mort96 5y agoThe context of the discussion is one where the difference between SoA and AoS is significant. It’s not always true in general that your program won’t be as efficient as possible, but it’s true in the context we’re discussing, where you have a lot of things (entities or whatever) and you’re iterating through them, which is what is being discussed. I was writing a direct answer to the question of “how can it be true that C++ isn’t built for modern machines even though modern games with good performance on modern machines use C++”. I think the answer is entirely correct in context.
- kaba0 5y agoFair enough, sorry I misunderstood your point.
- chromanoid 5y agoC++ is an issue for games. Most game engines implement a garbage collected script language (e.g. Lua, CLR, JavaScript...) to implement huge parts of game logic.
- mort96 5y agoThey’re not implementing game logic in those languages for performance reasons though. The question, as I interpret it, is about why C++‘s performance isn’t an issue for games. Using those languages for scripting/game logic is a trade-off where performance is sacrificed for developer productivity.
- chromanoid 5y agoYou are right. I misunderstood the question. I thought it was about the language as efficient tool not about performance. The Unreal engine is not even using data oriented design (at least for most parts), so I was assuming C++ sufficient efficiency was out of question. I agree with your argument, that the games would probably be faster. Game object processing is probably not the most pressing issue in games regarding performance, so I guess the impact would be not that visible (when talking about the stuff that is implemented in C++ in game engines).
- blakehaswell 5y agoC++ provides programmer control over memory layout, which is something managed languages don't provide. So although C++ is an older language and it isn't designed for modern machines, it does allow you the control to make performant programs for modern machines.