by Nginx487 · 6y ago · 0 comments
Good tendency however, now both C and C++ developers started experimenting with Rust, probably creating unified community and platform.
You have to use a subset of c++. Nobody agrees what that subset is. You have to be super-vigilant in code review. Features invite their use.
It's the lack of features in c that make it attractive. No magic. You want an object or a virtual, code it up if you really mean it is not just a keyword. You take responsibility for all the code running.
Every time I've cut a tonne of latency from a trading engine it's that. People relying on library and compiler without taking responsibility for it. STL is great. Except if you're actually performance critical, when you can beat it easily by solving your problem, not someone else's solution for everyone's possible similar problem.
That said, I tried to reproduce something similar, and it seems the issue only occurs in my example due to external linkage (adding 'static' fixes it)... but I can't claim this will always resolve the issue: https://gcc.godbolt.org/z/1vbqo3
Any argument that smart pointers are not zero cost to the language because they have a cost when you use them is a classic straw man argument.
Premise one: C++ has zero overhead for most of its features, like smarts pointers: if you don't use them, they cost nothing.
Premise two: using features like smart pointers adds a cost to your C++ program.
Conclusion (due to the strawman logical fallacy): C++ is not zero overhead because there exists a feature that has a cost if you use it.
I'd like to see the reasoning that leads to the same conclusion without resorting to the strawman logical fallacy.
But that's not the point - the point is that smart pointers never claimed to be zero-cost abstractions, AFAIK.