3 ms·
C++ is usually a premature optimisation. I would use it for something like the Unreal game engine, because I know that: - performance is important in much of
by Pitarou 10y ago
C++ is usually a premature optimisation.
I would use it for something like the Unreal game engine, because I know that:
- performance is important in much of the project
- the problem is complex enough to require high level language constructs
But for most tasks, my time would be better spent using a high-level language and then optimising the hot spots in, say, C.
- pjmlp 10y agoAnd Unreal does have opt-in support for GC in the C++ game objects.
- joejev 10y ago> - performance is important in much of the project At scale this always becomes true. C++ can be written with reference counting and other high level concepts with runtime penalties. When you need to optimize or scale, you will never need to look to another language. I do a lot of numerical computing in Python and often need to drop into Cython or C; in C++ this wouldn't need to happen. One the the main goals of C++ is that "there is no language below C++". High level language constructs are always nice, and C++ has a lot of "zero-cost" abstractions, meaning you only pay for what you need. For example, an iterator in C++ can just be a raw pointer in the case of iterating over a vector, but it is more complicated for a std::map because it is backed by a tree. C++ is a high-level language, so I don't understand the argument that you would be better off splitting your stack between the "important" parts and the slow parts.
- harry8 10y agoOverstated. There is a level below c++, namely assembly intrinsics. When it comes to simd code using sseN avxN you really do use them when performance is important. That's if you're staying on the CPU. Going massively parallel on a GPU? FPGA? C++ isn't as low as you go.
- MaulingMonkey 10y agoI'd have more time to optimize at these lower levels if I wasn't stuck babysitting C++ codebases to protect them from and fix their undefined behavior.
- Pitarou 10y agoBecause combining low-level performance and high-level abstraction in the same language comes at the cost of a heavy cognitive burden.
- tapirl 10y agoThe unreal game engine source code seldom uses the new c++1x features.