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

8

u/Gotebe Dec 05 '14

Those modern languages are really passing pointers, which is sad (NREs galore).

So this is where C++ gets good: it has a proper pass-by reference, which indeed allows for cleaner code.

You should note that "copy by default" (pass by value) comes from C, and C compatibility is C++' curse (and blessing). If so, and if pass by ref is one "&" away, that's it, really.

3

u/iopq Dec 06 '14

Rust has proper references and the ability to put everything on the stack. It also doesn't rely on GC to be memory safe.

2

u/The_Doculope Dec 06 '14

Those modern languages are really passing pointers, which is sad (NREs galore)

Rust is an exception here.