The Box of Delights

I’ve just finished reading John Masefield’s The Box of Delights (1935). I had picked it up at random in a tourist-trap gift shop several months ago, knowing only that it appeared vaguely Christmassy — not knowing at the time that it is (apparently) a giant of British Christmas pop culture, on par with The Nutcracker.

Read More

A better 404 polyglot

Between 2009-ish and 2018, StackOverflow’s 404 page displayed the following polyglot program:

# define v putchar
#   define print(x) ⏎
main(){v(4+v(v(52)-4));return 0;}/*

This program was originally due to Mark Rushakoff, who later proposed a shorter version: …

Read More

The STL is more than std::accumulate

Conor Hoekstra gives great talks on algorithms. Notably, “Algorithm Intuition” (C++Now 2019) and “Better Algorithm Intuition” (code::dive 2019). However, every time I watch one of his talks where he uses STL algorithms to solve some programming problem, I come away feeling like

Let's see who's really under that mask! Why, it's old Mr. Accumulate and his brother For_each!

Let’s look at two examples of “using STL algorithms to solve problems” in this limited sense, and how else we might solve them. Both of these examples are taken from Conor’s CppCon 2020 talk “Structure and Interpretation of Computer Programs: SICP.”

Read More

“Flash of unstyled base class”

This week I ran into an interesting bug in the unit tests for some multithreaded code. The setup for the test involved a “process status daemon” that (in production) polled some global state once per second, and also provided some auxiliary functions that we wanted to test. The “once per second” code came from an old and widely-used internal helper library. In this retelling, I’ve taken the liberty of updating it for C++20:

Read More

Type-erased UniquePrintable and PrintableRef

Here’s a simple type-erased UniquePrintable (owning, value-semantic, move-only), and a simple type-erased PrintableRef (non-owning, reference-semantic, trivially copyable). Notice that they use two different techniques internally, and that both techniques are simple enough to memorize and bang out in five minutes the next time you need type erasure.

Read More

Colonel Blimp and An Inspector Calls

TCM recently showed the 2011 restoration of The Life and Death of Colonel Blimp (1943), and I think it’s entered my pantheon of movies that I’ll watch any time they’re on — even considering its 163-minute running time. Like many an epic (e.g. Citizen Kane), Colonel Blimp brings the audience to understand, to respect — to love — its hero, in all his faults and glories.

Read More