4 ms·
You cannot count malloc as a way to allocate heap memory as a downside. It's for legacy reasons, and can't change due to the c interoperability. In the recent G
by shaklee3 8y ago
You cannot count malloc as a way to allocate heap memory as a downside. It's for legacy reasons, and can't change due to the c interoperability. In the recent Go best practices story, the author said there are at least 6 ways to declare a variable in Go. That's a language with no backwards compatible of any other language.
- zanny 8y agoYes you absolutely can, because the second you are writing C++ code with anyone but yourself you will eventually find, and have to rewrite, something someone wrote using malloc in C++. I've found code where developers casted perfectly useful data structures to void* for no reason to then index into it by memory offset to access its fields, I've seen well architected concurrent classes destroyed by consumers "friending" it and then directly addressing internal private data meant to be guarded via accessor functions, and more. C++ gives you infinite ways to shoot yourself in the foot, and even if you are the savant genius god programmer who manages to navigate its neck deep swamp of complexity your coworkers or even worse random strangers you collaborate with on the Internet absolutely won't.