4 ms·
>* Avoiding dynamic memory allocations. In languages like Python all memory allocation is dynamic. However, unloading/loading the same object over and over is s
by cube13 15y ago
>* Avoiding dynamic memory allocations. In languages like Python all memory allocation is dynamic. However, unloading/loading the same object over and over is something I've seen a lot of.
I don't think that C really teaches you to avoid dynamic allocation. In a lot of situations, it's unavoidable, especially if the program needs more memory allocated than the stack will allow.
What C teaches, as you said in the first point, is memory management. You don't use mallocs without knowing exactly when the memory is free'd, don't allocate new memory unless you actually need to, etc. C forces you to make decisions about how you're using the memory, whether you can stack allocate it, if it needs to be heap allocated, and when it needs to be destroyed.