Move semantics, and why copies are expensive
A pointer copied twice will free the same memory twice. Following that bug to its fix explains deep copies, r-value references, and what moving an object really is.
Category edition · 7 articles
Memory, lifetimes, and the build model, taken from C++ and pointed back at the languages that hide them.
From the archive
7 filed
A pointer copied twice will free the same memory twice. Following that bug to its fix explains deep copies, r-value references, and what moving an object really is.
C++ has no finally block and does not need one. Destructors run at a known point, in a known order, and that guarantee is what replaces defer and try-with-resources.
Source becomes object code, object code becomes a program, and the linker sits between them. The model that go build and every bundler hide from you.
A frame gets pushed, a frame gets popped, and the ceiling was fixed when the thread was created. Which is why goroutines are cheap and Node has a maximum call stack.
C++ makes every function state whether the callee gets a copy, another name for your object, or an address that might be null. Go asks the same thing, quietly.
A base-class pointer holding a derived object runs the base method. Why C++ binds at compile time, what virtual costs per object, and how Go's itab differs.
A constructor cannot return an error code, so C++ throws. The std::exception tree, what catching a base class buys you, and where errors.As lands.