4 ms·
> If you're using C++, you want speed and/or memory efficiency. Generic libraries won't give you that. The standard libraries should, in that they can have Spo
by msla 7y ago
> If you're using C++, you want speed and/or memory efficiency. Generic libraries won't give you that.
The standard libraries should, in that they can have Spooky Deep Knowledge of the compiler and other standard libraries which external code won't, like how there's no way to add two ints which is faster than the standard + operator.
- jeffreygoesto 7y agoWell, this argument goes both ways, a generic implementation can never leverage special properties of your data. See i.e. Alexandrecu's talk [0] at about 1:05ff. If as a company you have special use cases or guidelines, you may easily benefit from libraries using these properties. [0] https://youtu.be/FJJTYQYB1JQ https://youtu.be/FJJTYQYB1JQ
- danbolt 7y agoI think you're right that some things, such as integer addition, are quick and don't require a lot of thought, but a lot of teams leaning to C++ stems from larger-scale performance considerations that aren't one-size-fits-all. A simple example is `std::vector`. The structure is a nice resizable array, but for a long time you couldn't override the allocator and the performance of your application could be affected by heap fragmentation or even just the performance cost of heap allocations. A lot of C++ shops often wrote their own replacement containers that had a better allocation strategy. The design needs of a PlayStation 2 programmer ended up being different than an x86 desktop computer with virtual memory.