News for hackers. Stuff that matters.
Re:The compiler will optimize that away by xiaodai on Monday May 03, 2021 @03:43AM (#27022594)
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.

Re:The compiler will optimize that away by mort96 on Monday May 03, 2021 @07:14AM (#27023659)
If 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.

Re:The compiler will optimize that away by kaba0 on Monday May 03, 2021 @04:59PM (#27030560)
> 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.

Re:The compiler will optimize that away by mort96 on Monday May 03, 2021 @05:33PM (#27030992)
The 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.

Re:The compiler will optimize that away by kaba0 on Monday May 03, 2021 @05:47PM (#27031160)
Fair enough, sorry I misunderstood your point.
Re:The compiler will optimize that away by blakehaswell on Tuesday May 04, 2021 @02:37AM (#27034654)
C++ 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.
Re:The compiler will optimize that away by chromanoid on Monday May 03, 2021 @10:31AM (#27025555)
C++ 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.
Re:The compiler will optimize that away by mort96 on Monday May 03, 2021 @05:38PM (#27031071)
They’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.
Re:The compiler will optimize that away by chromanoid on Monday May 03, 2021 @06:30PM (#27031681)
You 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).