HackerTubewatch
Surprise me
Frame from CppCon 2015: Andrei Alexandrescu “Declarative Control Flow" Plays via YouTube's privacy-enhanced embed

CppCon 2015: Andrei Alexandrescu “Declarative Control Flow"

48 videos recommended on HN
YouTube
2 HN users recommended this talk2 months2016–2022 score 2
Years with an HN recommendation, 2007–2026

Pointed to in threads on defer, scope_exit and RAII as the clearest treatment of scope guards.

Andrei Alexandrescu's CppCon 2015 talk on handling exceptional control flow declaratively in C++. It uses scope guards with success and failure variants, built on std::uncaught_exceptions, to replace ad hoc RAII classes and rethrowing try/catch blocks.

“Andrei Alexandrescu has a fun talk about implementing scope_exit” (HN, 2018)

2 recommendations · 3 citations · Talks · advanced

5 Hacker News comments

From the HN archive; up to 20 kept per video, favoring different commenters. Recommendations first.

@Ace17 Jul 2016 Recommends
on HN thread Memory management in C programs (2014)
Google is an example that writing production code that doesn't use exceptions is possible, not that this is the right thing to do. They said that their decision was primarily legacy-motivated (in short, they were fearing that introducing exceptions in a non-RAII codebase would lead us to a long period of instability). I'll add that in some situations (e.g when freeing resources) the control flow gets very convoluted, and you don't want to deal with directly. See: Andrei Alexandrescu - Declarative Control Flow ( [this video] )
Alexandrescu on declarative control flow for convoluted resource cleanup
@uep Feb 2018 Recommends
on HN thread Scope exit in C++11 (2012)
Andrei Alexandrescu has a fun talk about implementing scope_exit using a new C++17 function: std::uncaught_exceptions (which is a tweak to std::uncaught_exception). Fundamentally, it doesn't really solve the destructor throwing exceptions issue though. [this video]
Fun talk on implementing scope_exit with std::uncaught_exceptions

Citations, criticism and jokes

@dnautics Dec 2020 Cites it
on HN thread A Defer Mechanism for C
yes, you always run defer. I don't see it in this proposal, but Most languages/frameworks that implement a defer also implement a "error defer" which only gets triggered on some sort of labeled early exit scenario, and some implement "success defer": (i believe this is scopeguard: [this video] )
Explains scope guard with success and failure variants
@einpoklum Oct 2022 Cites it
on HN thread A Tour of C++ (Third edition)
A count of the number of exceptions in-flight was added, replacing the boolean indication of whether an exception is in-flight. This allows the scope guard construct proposed by Andrei Alexandrescu to distinguish between a scope being left on success and on an exception being thrown. YouTube video about scope guard: [this video] Description of the change to the standard: [link]
Video about scope guard motivating the uncaught_exceptions change

Video list and Hacker News comment labels from HackerTube (prompted by @karpathy), released under ODC-By 1.0, built on the open-index/hacker-news archive. Hacker News data is provided by Y Combinator; comments remain the work of their authors. Video titles, channel names and thumbnails belong to their creators and are shown via YouTube. HackerTube Watch is an unofficial edition. Data export of 2026-10-31.

Keyboard shortcuts

/
Search
j k
Next / previous video
r
Surprise me
l
Like (video page)
w
Watch later (video page)
?
This help
Esc
Close