what makes programming languages like go and rust memory-safe and c++ not?

696 views

what makes programming languages like go and rust memory-safe and c++ not?

In: Technology

5 Answers

Anonymous 0 Comments

Short answer, “Pointers”. Long answer and in case you don’t know, A pointer is basically an object that points to a location in memory. C++ is pretty lax in how you create and destroy pointers and the objects they may or may not point to. It allows you to declare a pointer without initializing or allocating the location of the memory it’s pointing to (aka a Null pointer). It also doesn’t take care of Dangling pointers i.e. a pointer where you point to an object that has been deleted or de-allocated.

C++ is basically a language that assumes the programmer knows what they are doing and is more than willing to give you anything you need. Even if that leads to memory leaks, buffer overflows, and null reference exceptions. As my old C++ professor loved to say “C++ is a lovely language eager to give you all the space and rope you need… to hang yourself.”

You are viewing 1 out of 5 answers, click here to view all answers.