3 ms·
> If the complexity can be reduced (by say, adding garbage collection) Adding a garbage collector would make code more complex, not simpler, as it would break
by KayEss 8y ago
> If the complexity can be reduced (by say, adding garbage collection)
Adding a garbage collector would make code more complex, not simpler, as it would break RAII. I spend a lot more time dealing with memory and resource allocation issues in GC languages than I do in C++.
In languages like Python we have to use `with`, and this is harder to use in the client code, and the class is much harder to write, than anything in C++ where we just add a destructor to clean up.
std::vector<char> data(10 << 20);
std::ifstream("/dev/urandom", std::ios::binary).read(data.data(), data.size());
The above code can never leak (either memory or file handles) under any circumstances and the implementations of the types involved push zero overhead/boilerplate on me as a user of them.
I think if you want to reduce complexity of C the place that everybody else is looking is at how to allow opting in and out of legacy support.