Hacker News new | ask | show | jobs
by jb1991 1188 days ago
Go is a garbage collector. Smart pointers are not.

It's fairly simple:

instead of new --> make_unique(); this returns a pointer, but it will automatically delete its memory when it goes out of scope.

instead of delete --> do nothing; the memory is deleted when you don't need it any more.

There are additional API methods on the unique pointer that allow you to do other things for flexibility, but while continuing that memory safety.

This is nothing at all like a GC language like Go.