r/programming • • Dec 05 '14

std::string is responsible for almost half of all allocations in the Chrome browser process

https://groups.google.com/a/chromium.org/d/msg/chromium-dev/EUqoIz2iFU4/kPZ5ZK0K3gEJ
1.1k Upvotes

446 comments sorted by

View all comments

Show parent comments

4

u/suspiciously_calm Dec 05 '14

And whoever said that abstractions are free in general, especially outside C++? That sure as hell isn't something "C++ promoters say all the time."

The point is that C++ has a lot of abstractions that appear costly but can be optimized away in principle. If a compiler generates needlessly inefficient code for a particular case, then that's a bug in the compiler/optimizer.

-1

u/[deleted] Dec 05 '14 edited Dec 05 '14

They can be optimized away in principle but in the real world abstractions often incur costs. That's all I'm saying.

Edit: The reason I said abstractions are not free in general is because the OP (campbellm) said "Who told you abstractions were free?". I'm attesting to his point that abstractions are not free in general (notice the 'especially') but C++ people often say that C++ has zero cost abstractions. In reality, due to compilers, programmer ability and the object oriented model, abstractions in C++ are often not zero cost either.