Here's a good talk by the inventor of C++, Bjarne Stroustrup: Make Simple Tasks Simple. I think it's a really good talk, and it discusses my main beef with "university C++": Every single course I've seen, every single person I've talked to who has had C/C++ at university, they all tell the same thing - they don't learn a single thing about when to use the stack or the heap. I've helped out a friend with their programs once, their professor's tactic was just "always use new, never use anything else, if you do it any other way, you're failing the class".
Bjarne's approach is so damn simple - always use the stack (and don't worry about memory management, the stack clears itself) unless you explicitly need to pass data around outside of your scope, only then use the heap (but use a shared_ptr and don't worry about memory management, because a shared_ptr cleans up after itself).
4
07 Jul 2015 09:24
u/milch
in v/programming
Here's a good talk by the inventor of C++, Bjarne Stroustrup: Make Simple Tasks Simple. I think it's a really good talk, and it discusses my main beef with "university C++": Every single course I've seen, every single person I've talked to who has had C/C++ at university, they all tell the same thing - they don't learn a single thing about when to use the stack or the heap. I've helped out a friend with their programs once, their professor's tactic was just "always use
new, never use anything else, if you do it any other way, you're failing the class".Bjarne's approach is so damn simple - always use the stack (and don't worry about memory management, the stack clears itself) unless you explicitly need to pass data around outside of your scope, only then use the heap (but use a
shared_ptrand don't worry about memory management, because ashared_ptrcleans up after itself).