December 28, 2025
Finally? C++ brought a mop
C++ says "We have try at home."
Coders battle over C++’s “cleanup at home”: clever hack or chaos
TLDR: Raymond Chen explains C++ uses destructors instead of a “finally” step, and throwing during cleanup can crash apps. Comments split between RAII fans, Swift’s defer lovers, and C++ skeptics joking about readability and memes—because how we handle errors decides whether software fails gracefully or flames out.
Microsoft legend Raymond Chen dropped a spicy holiday post: while Java, C#, Python, and JavaScript have try…finally (a guaranteed cleanup step after code runs), C++ shrugs and says, “we’ve got that at home,” using destructors and tools like wil::scope_exit. Translation: in C++ you attach cleanup to an object that auto-runs when you leave a block. The catch? If that cleanup throws an error while another error is already happening, C++ can terminate your program. Other languages often replace the original error with the new one, which brings its own drama.
The comments lit up like a code review. One reader called out the meme-y title for missing the word “finally,” flexing the “we have X at home” joke roots, while Swift fans swooped in with “just use defer,” a simple end-of-scope cleanup that feels more chill. The RAII crowd (that’s “clean resources when an object goes out of scope”) came in hot, calling destructors superior because they save you from remembering cleanup everywhere. Meanwhile, the snark brigade wondered if C++ syntax ever becomes readable without an fMRI and coffee IV. And yes, someone poked the timeline, asking how old the “Python 3.2 is now” line is.
Verdict from the peanut gallery: C++ cleanup is powerful, but unforgiving. Other languages are cozier. The meme writes itself.
Key Points
- •C++ lacks a native finally clause and uses destructors/RAII to run code when exiting a scope.
- •WIL’s wil::scope_exit places a lambda in an object whose destructor executes on scope exit, emulating finally.
- •If no exception occurs in the guarded block, an exception in finally/destructor is thrown from the try block across languages.
- •When both the guarded block and cleanup throw, Java, C#, Python, and JavaScript propagate the cleanup exception (Python 3.2 keeps original as context).
- •In C++, an exception escaping a destructor during stack unwinding triggers program termination; WIL provides scope_exit_log to log and ignore such exceptions.