All guides
Every guide, newest first. Browse by topic instead, or read the daily tips and puzzles.
-
Taking a Real Codebase to mypy --strict Python
Migrate a real 191-line Python script to mypy --strict: the interpreter fix, the annotation pass, the Any elimination, coded ignores, the Protocol decision, and the PEP 695 conversion — every error quoted from the actual runs.
-
Installing a Header-Only C++20 Modules Library with CMake C++
CMake rejects INTERFACE libraries with a CXX_MODULES file set. This guide shows the failure on CMake 3.28.3, then installs the same module as a static library and consumes it with find_package — every step run.
-
CMakePresets and vcpkg on a Real C++20 Modules Project C++
Four preset and vcpkg decisions on a real C++20 modules project: where VCPKG_ROOT lives, manifest versus classic mode, chainloading a second toolchain, and preset inheritance with GCC 16.
-
Bash Strict Mode, Tested: Six Traps, Each Failing and Then Fixed Sysadmin
A small archive script with a bats test for every strict-mode trap: function-as-condition, local masking, command substitution, the ERR trap without -E, pipelines without pipefail, and the ((count++)) false failure. Every trap is shown failing first, then fixed, on bash 5.2.21.
-
Tokio Backpressure: Bounded Channels and Semaphore-Limited HTTP Fan-Out Rust
Bound a Tokio pipeline at both ends: a bounded mpsc channel that parks the sender, and a semaphore whose placement decides whether 50 tasks exist or 5 do — tested with Tokio 1.53.2 and Rust 1.99.1.
-
The C++20 Spaceship Operator: One Defaulted <=> Replaces Six Comparisons C++
Migrate a small value type from six hand-written comparison operators to one defaulted C++20 three-way comparison — with the signed/unsigned, NaN, and missing-
traps. -
Build a C++ Ranges Pipeline: C++20 Views, Then C++23, With the Compiler Matrix C++
Build one log-record pipeline twice: C++20 filter, transform, drop, and take over a named owner container, then the C++23 upgrade with enumerate, zip, chunk_by, slide, stride, and cartesian_product, ending in ranges::to — tested on GCC 13, 14, 16, and Clang 18.
-
Build Your Own Mini-Git: Objects, Trees, Commits, Packfiles C++
Reimplement Git's storage model in stdlib Python so your program produces hashes and objects real Git accepts — loose objects, trees, commits, tags, and a hand-written packfile, all verified against Git 2.43.0.
-
Migrating a Template Library from SFINAE to C++20 Concepts C++
Migrate a small describe() library from enable_if to C++20 concepts in three steps, keeping the runtime output identical — with the real compiler errors before and after, and the subsumption trap that decides whether the migration works.
-
GCC 16 Defaults to C++20 C++
GCC 16 changes the default C++ standard to C++20. Pin first, then fix each breakage class in order. Every error below was produced on GCC 16.2.0.
-
C++23 std::mdspan and Deducing This C++
Build a matrix and image view library with C++23 std::mdspan: row-major, column-major, and strided channel views, plus deducing this member functions. Tested on GCC 16, 14, and 13, with the failures quoted.
-
C++23 std::expected Error-Handling Pipelines C++
Build a CSV parser whose every fallible step returns std::expected and chains with and_then, transform, or_else, and transform_error — with the same-error-type rule, the void step, and the real compiler results on GCC 13 and Clang 18.
-
C++20 Modules with CMake 3.28 and Ninja C++
Build a small C++20 geometry library as a named module with partitions, wired through CMake 3.28 and Ninja, and tested on Clang 18 and GCC 13 — including the setups that fail.
-
C++20 Coroutines to C++23 std::generator C++
Write a coroutine generator from scratch with a promise type, Task, and Generator, then replace it with C++23 std::generator and pipe it through ranges views — tested on GCC 13 and GCC 14, with the GCC 13 failure and the single-pass crash shown.
-
The binding that copied C++
A short C++ program with a bug: the binding that copied. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
The overload that hid the other one C++
A short C++ program with a bug: the overload that hid the other one. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
auto that did not copy C++
A short C++ program with a bug: auto that did not copy. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
The future nobody kept C++
A short C++ program with a bug: the future nobody kept. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
The derived object that arrived as a base C++
A short C++ program with a bug: the derived object that arrived as a base. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
A declaration disguised as a variable C++
A short C++ program with a bug: a declaration disguised as a variable. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
The loop variable every lambda shares C++
A short C++ program with a bug: the loop variable every lambda shares. The answer, the observed output, the fix, and the lesson are in this tutorial.
-
A sorted map backed by vectors (std::flat_map, C++23) C++
std::flat_map keeps keys sorted like a map but stores them in vectors, so iteration is cache-friendly and there is no per-node allocation.
-
A thread that stops itself cleanly (std::jthread) C++
std::jthread joins at destruction and carries a stop token, so the two classic thread bugs — a forgotten join and a thread with no way to stop — are both gone by construction.
-
enumerate instead of a manual counter (C++23 ranges) C++
std::views::enumerate pairs each element with its index, so the loop body never maintains a counter by hand.
-
A lazy pipeline with std::generator C++
A coroutine returning std::generator produces values on demand: nothing runs until the caller iterates, and nothing is stored.
-
One function instead of const/non-const overload pairs (deducing this) C++
An explicit object parameter lets one function see whether it was called on a const object, replacing the duplicated overload pair.
-
Constrain a function with a concept, in the parameter list C++
An abbreviated function template puts the constraint where the parameter is declared. A wrong argument type is a compile error naming the concept, not a page of template errors.
-
Return errors as values with std::expected C++
std::expected
carries either a value or an error, so error paths stay visible in the type instead of hiding in exceptions or out-parameters. transform maps the value and passes errors through untouched. -
Rust Lazy Statics, Measured: OnceLock vs LazyLock vs lazy_static — and the 2x Claim That Does Not Reproduce Rust
Three ways to build a lazy static in Rust, measured: steady-state access and contended first init. OnceLock is 1.24x faster than lazy_static, not 2x.